PDF Table Rendering Slow

Let me start off by saying that I understand that making a table in a PDF is a little bit more difficult than creating a DOC since you have to draw all the lines for a table as opposed to just saying “let there be a table”.

But I modified the DocumentBuilderDemo to expand the table to 5000 rows. The DOC takes 3-4 seconds, but the PDF is taking around 2 minutes. Is there any way to speed this up?

BUMP…still waiting on a reply.

Hi

Thanks for your request. You are right rendering takes much more time than just saving documents. The average speed of converting to PDF using Aspose.Words is 10 pages per second.

Could you please attach your output Word document here for testing? I will check it and provide you more information.

Best regards.

The funny thing is that using PDFSharp I can create a table of similar size in about 5 seconds.

I have attached both the DOC and PDF that is created by calling doc.Save

Hi

Thanks you for additional information. Most of conversion time takes building page layout of the document. I used the following code for testing:

DateTime p1 = DateTime.Now;
Document doc = new Document(@"Test001\Aspose[1].Words.Demos.doc");

DateTime p2 = DateTime.Now;
doc.UpdatePageLayout();

DateTime p3 = DateTime.Now;
doc.SaveToPdf(@"Test001\out.pdf");
DateTime p4 = DateTime.Now;

Console.WriteLine("Reading document into the DOM: {0} sec", (p2 - p1).TotalSeconds);
Console.WriteLine("Building page layout: {0} sec", (p3 - p2).TotalSeconds);
Console.WriteLine("Saving to PDF: {0} sec", (p4 - p3).TotalSeconds);
Console.WriteLine("Total time: {0} sec", (p4 - p1).TotalSeconds);

Here is my result:

Reading document into the DOM: 1,8811076 sec
Building page layout: 102,7928794 sec
Saving to PDF: 10,6286079 sec
Total time: 115,3025949 sec

As you can see saving to PDF takes only 10 seconds, but building page layout of the document takes about 100 seconds. PDFSharp does not convert Word documents to PDF, so it does not need to build page layout. That is why creating PDF from scratch takes less time than converting Word to PDF.

Best regards.

So when you do this:

doc.Save(“Aspose.Words.Demos.pdf”, SaveFormat.Pdf, SaveType.OpenInApplication, Response);

It creates a word document first and converts it to a pdf? Wouldn’t it be better and faster to code you library to generated the pdf directly?

Hi

Thanks for your inquiry. Not actually. Aspose. Words is designed to works with MS Word documents, which are flow documents, i.e. they are not layout into pages. So when you call SaveToPdf method, page layout of the document is built and then it is saved to PDF.

Best regards.

Thanks…unfortunately we won’t be able to purchase a site license for your product until you make MAJOR speed improvements to your document generation library.

Hi

Thank you for your interest in Aspose.Words. May I ask you, you need to generate Word documents or PDF document? If you need to generate Word document Aspose.Words is just what you need. But if you do not need to generate Word documents, and just need to generate PDF document, then you should consider products like Aspose.Pdf.

Best regards.