Jeffrey Fuller
Jeffrey Fuller

Reputation: 300

How would I convert a HTML5 / CSS3 document to PDF?

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

Upvotes: 13

Views: 30863

Answers (6)

Mark Storer
Mark Storer

Reputation: 15868

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.

Upvotes: 5

dwjohnston
dwjohnston

Reputation: 11803

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.

Upvotes: 1

charpdevel0p3r
charpdevel0p3r

Reputation: 346

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

Upvotes: 1

foolip
foolip

Reputation: 1614

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

Upvotes: 2

rsenna
rsenna

Reputation: 11963

Some options (all proprietary):

For open-source alternatives, please see here:

Open Source HTML to PDF Renderer with Full CSS Support

Upvotes: 1

Lachezar
Lachezar

Reputation: 6703

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.

Upvotes: 1

Related Questions