Hello,
we evaluate Aspose.Words for .NET before purchasing a license. We use the latest version 22.9 with the trial license that you sent to the email.
We notice that the docx to PDF conversion works at least 10x slower than with version 17.8, for which we have purchased a license. We test on a completely simple document containing only a few words.
To convert with both versions, we use the following code:
MemoryStream memoryStream = new MemoryStream(File.ReadAllBytes(@"C:\Temp\Aspose\Simple.docx"))
var doc = new Document(memoryStream);
MemoryStream outStream = new MemoryStream();
doc.Save(outStream, SaveFormat.Pdf);
doc.Save(outStream, SaveFormat.Pdf);
Do we need to use any additional code to make it work faster? For simple document with few words it takes 1.5 second.
@uros.joras Actually 1.5 seconds for a simple document is quite long time. I suspect this is time of initial conversion of the document. Such long time can be explained because on initial call Aspose.Words collects the fonts available on the machine, since the fonts are required for rendering document to Fixed Page formats. For example if measure the time like this:
Stopwatch sw = new Stopwatch();
sw.Start();
Document doc = new Document(@"C:\Temp\in.docx");
doc.Save(@"C:\Temp\out.pdf");
sw.Stop();
Console.WriteLine(sw.ElapsedMilliseconds / 1000d);
the time of conversion is 1.4 seconds. But if measure the time using code like this:
// This code make Aspose.Words to index the fonts available on the machine
Document tmp = new Document();
tmp.UpdatePageLayout();
Stopwatch sw = new Stopwatch();
sw.Start();
Document doc = new Document(@"C:\Temp\in.docx");
doc.Save(@"C:\Temp\out.pdf");
sw.Stop();
Console.WriteLine(sw.ElapsedMilliseconds / 1000d);
Returned time is 0.5 seconds. So to make conversion work faster, you can make an initial call of UpdatePageLayout
on your application start, so the initial conversion does not take longer than subsequent calls.