4

I am trying to generate a PDF file based on a dynamically generated HTML report that our webapplication has generated.

The HTML generation and rendering is fast (1-4s) except in older browsers (IE6/IE7), but when I use either one of the mentioned PDF components to generate the PDF version, it can take up to several minutes.

For instance I have an HTML report that contains only text - approximately 1 million characters - which takes ~28s to convert to a PDF file, which is only 1.15MB in size and ~250 pages.

Is there any way to optimize the HTML, to make the job easier for the PDF components?

Good Samaritan
  • 706
  • 1
  • 7
  • 21
  • 1
    the less formatting etc. occurs in the HTML the easier it is... are you by any chance referencing some external file (like CSS or JS) which they try to GET which in turn makes them wait for a timeout to occur ? – Yahia Oct 10 '11 at 08:52
  • I use aspose at times but did find PDF conversion sluggish in my case (I was trying to convert TIFF files to PDF, which may or may not call on the same code). They are very responsive however, so I'd recommend logging a call and sending them examples. I ended up using GDPicture instead, but if you need it from HTML Aspose may be the best. Can you post the code that converts the HTML using aspose? – Glinkot Oct 10 '11 at 09:00
  • @Yahia After step debugging some, it seems that it is the call to the PDF component that takes up 90% of the time, and at this time the CSS is already part of the HTML - I use a StreamReader to read an external CSS file, and inline the CSS with the HTML. – Good Samaritan Oct 10 '11 at 09:07
  • @Good Samaritan I understand but please check the HTML that you feed into the component for any external references (perhaps you inline the CSS but still have the reference in there)... – Yahia Oct 10 '11 at 09:13
  • @Glinkot I have bought a license for the ExpertPDF component, but have also tested against the Aspose component for speed comparison. When they both performed "equally bad", I reckoned that maybe I could optimize my code someway. I used sample code from their website when testing Aspose. – Good Samaritan Oct 10 '11 at 09:14
  • @Yahia I have double-checked the HTML, but could not find any external references. Thanks, though! – Good Samaritan Oct 10 '11 at 10:07

6 Answers6

2

I think you need to check below component for you question..

They give online demo for checking conversion....

http://www.essentialobjects.com/Products/EOPdf/Default.aspx

http://www.winnovative-software.com/

For Ref: Check out this page answer and it's comments...

Convert HTML to PDF in .NET

Community
  • 1
  • 1
sikender
  • 5,883
  • 7
  • 42
  • 80
  • 1
    Wow, I gave EO PDF a try, and it actually outperformed the other components by a factor of 3 in my tests! This is great, thanks!:) – Good Samaritan Oct 19 '11 at 07:57
1

It would be better if you could share a sample input HTML file along with the code snippet. Moreover, we have recently published a newer version of Aspose.Pdf for .NET (version 6.3.0). Please try with that and see if it helps in your scenario. If you still find the same issue then I would recommend you to post the query along with input HTML and code snippet in Aspose.Pdf forum. Our support team will further investigate it and guide you accordingly.

Disclosure: I work as developer evangelist at Aspose.

Shahzad Latif
  • 1,408
  • 12
  • 29
1

Better try to avoid HTML --> PDF conversion if you can - it makes lots of problems sometimes.

I've tried two other approaches (both are free of charge) and both are working very well, although are much different:

  • Use Microsoft Reporting RDLC templates. Has nice and easy designer in Visual Studio. What you have to do is just to create a template, fill it with some data in code and that's all. It's fast, easy to use and maintain. I'm currently using that in many webapps and I'm very happy with it.
  • Use iTextSharp library. It blazingly fast. You can generate PDFs from XML or from code (which can be a drawback in complex PDFs, but gives you full control if you need it).
Piotr Szmyd
  • 13,371
  • 6
  • 44
  • 61
  • +1 for the iTextSharp suggestion. It really is fast and provides more control that we often get with HTML and CSS (mostly because of the rendering engines the converters use). – Bernhard Hofmann Jun 15 '16 at 07:20
1

You can try XF Rendering Engine from Ecrion Software(www.ecrion.com). They have also a WYSIWYG designer.

Thanks

Bogdan M.
  • 1,128
  • 1
  • 9
  • 23
0
  1. First what i did to improve performance of conversion is to convert my report html in box structure with the help of designer
  2. I used this component Winnovative HTML to PDF Converter
0

I have used in many projects, its faster and stable. Try follwoing
http://code.google.com/p/dompdf/

aquasmit
  • 411
  • 2
  • 8