13

We're currently generating reports for our web application using html5 / css3, and they look good on screen, but obviously when the user hits print who knows what is going to come out of the printer. So, what I would like to know is what is the best way to convert these reports to PDF for download / printing while maintaining the same visual quality of the on screen reports.

Update 2010-10-26 16:01: We're using both .NET and Perl

Jeffrey Fuller
  • 300
  • 1
  • 2
  • 8

6 Answers6

6

The only think I can think of that might work is wkHTMLtoPDF. It's a QT app that sits on top of WebKit to generate its PDF.

The good news is that it even evaluates JS so just about anything goes.

The other good news is that QT is available across a wide selection of platforms. Whatever you might be using, chances are you can use QT.

Mark Storer
  • 15,672
  • 3
  • 42
  • 80
  • I think we may have a build server setup with this, and we'll just setup a service that receives the static files, and returns a nice pdf – Jeffrey Fuller Nov 04 '10 at 14:20
  • We'll be evaluating it for our own purposes in the near future. Let me know how it goes. – Mark Storer Nov 04 '10 at 16:42
  • 3
    Qt is more than 'an X11 windowing thingy' :) http://en.wikipedia.org/wiki/Qt_(framework) – Sam Dutton Dec 06 '11 at 17:13
  • this library does not support CSS3 – LI HO TAN Jun 23 '21 at 09:41
  • If you have a look at https://en.wikipedia.org/wiki/Comparison_of_browser_engines_(CSS_support) you'll see that no browser fully supports css3, but all of them support some of it. Which parts they support vary. wkhtmltopdf is also not using the most recent version of WebKit. Depending on what you're using, the web kit embedded will be 2 to 9 years old. – Mark Storer Jun 25 '21 at 13:05
2

Try Prince XML, the results are pretty to look at.

foolip
  • 1,604
  • 14
  • 11
1

ExpertPdf (www.html-to-pdf.net) supports html5 / css3.

You can try the online demo here: http://www.html-to-pdf.net/free-online-pdf-converter.aspx

charpdevel0p3r
  • 346
  • 2
  • 2
1

If you are using some of the new HTML5 elements like Canvas, then probably even the popular PDF converter wont help you.

I suggest you to put suitable print-friendly version of your CSS. This could be achieved by using media="print" attribute in the <link rel="stylesheet"... tag of a separate CSS file, which is containing the definitions for print version.

Lachezar
  • 6,523
  • 3
  • 33
  • 34
1

Some options (all proprietary):

For open-source alternatives, please see here:

Open Source HTML to PDF Renderer with Full CSS Support

Community
  • 1
  • 1
rsenna
  • 11,775
  • 1
  • 54
  • 60
1

There is a node module html5-to-pdf that works pretty well.

Is free and open source.

It runs on Electron. There are some bugs (for example anchor tags render the hyperlink as well) - but it might be an easy fix.

dwjohnston
  • 11,163
  • 32
  • 99
  • 194