Convert XPS to PDF takes for long

<span style="font-size:11.0pt;font-family:"Calibri",sans-serif;

color:#1F497D">We have a licensed Aspose.Pdf ver 9.6 and I am trying to
evaluate if we need to purchase the current version 10.7 to have any better
performance gain converting PDF to XPS and vice versa. Both version has
about the same performance. For a 1.5 mb PDF file with very little
images, it takes about 35~ sec converted to XPS. However, it takes
forever long 15mins still not completed to reverse it back to pdf format.
Do you have any idea if I make any coding mistake here? Below is my sample code.

string asposeTime;

string nixpsTime;

string filename = System.IO.Path.GetFileNameWithoutExtension(pdfFilepath);

string dir = System.IO.Path.GetDirectoryName(pdfFilepath);

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(pdfFilepath);

// Instantiate XPS Save options

Aspose.Pdf.XpsSaveOptions saveOptions = new Aspose.Pdf.XpsSaveOptions();

// Save the XPS document

string outputpath = string.Format("{0}\\{1}-Aspose.xps", dir, filename);

Stopwatch sw = new Stopwatch();

sw.Restart();

pdfDocument.OptimizeResources();

pdfDocument.Save(outputpath, SaveFormat.Xps);

sw.Stop();

asposeTime = string.Format("Aspose(ms) " + sw.ElapsedMilliseconds.ToString());

using (var stream = File.OpenRead(outputpath))

{

byte[] data = new byte[stream.Length];

stream.Read(data, 0, data.Length);

stream.Close();

using (MemoryStream ms = new MemoryStream(data))

{

Aspose.Pdf.LoadOptions options = new XpsLoadOptions();

//options.LoadFormat = LoadFormat.XPS;

using (Aspose.Pdf.Document doc = new Aspose.Pdf.Document(ms, options))

{

string output = string.Format(@"{0}\\{1}.pdf", System.IO.Path.GetDirectoryName(outputpath),

System.IO.Path.GetFileNameWithoutExtension(outputpath));

using (FileStream stream1 = new FileStream(output, FileMode.Create))

{

//doc.OptimizeResources();

doc.Save(stream1, Aspose.Pdf.SaveFormat.Pdf);

}

}

}

}

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman",serif;}

<![endif]–>

Hi there,


Thanks for your inquiry. I have tested the scenario using your code with some sample PDF documents and Aspose.Pdf for .NET 10.7.0, but unable to noticed the reported lag. It is taking around 7 second for PDF to XPS and 2-3 seconds for XPS to PDF back. It seems it is file specific issue. We will appreciate it if you please share your sample source PDF document here, we will look into it and will guide you accordingly.

We are sorry for the inconvenience caused.

Best Regards,