1

I have a requirement to put up some content (a large number of reports) in a website (as webpages) as well as PDF documents. The web pages will be fairly simple, as they are converted from Markdown or AsciiDoc.

I would like to style these pages using HTML5 and CSS3, and define print output with CSS3 paged media. The problem I am having is I'm unable to find a good rendering tool to convert HTML5+CSS3 paged media to PDF.

What I found so far:

  1. I checked wkhtmltopdf, but it appears that it has a problem with @page and @media print {}.
  2. O'Reilly's HTMLBook looked promising, but looks like their tools are internal.
  3. Prince apparently does the job, but it is very expensive. I need a free tool.

Can anyone suggest a tool that,

  1. renders HTML5+CSS paged media into PDF
  2. is free (to be used in my own project, which will be free and open source)
  3. conforms to HTML5 and CSS3 standards as much as possible?
  • Thanks, Krumia! AFAIK Prince is free for personal use, even if the results are published (non-commercially that is) – I use it for my books this way. So what speaks against it? The only technical difference is that with a license the tiny watermark in the upper-right corner of the first page is disabled. And from all the tools I've tried, it does the job best. – Izzy Sep 7 '15 at 15:53
  • You could simply use a web browser's printing functionality and deactivate any extra information they add (e.g. URI and time stamps). – ComFreek Sep 7 '15 at 16:39
  • @ComFreek: I want to email the PDF as well. If I can't convert the webpages to PDF, I will have to manually create PDF's with same styling, which would be lot of code. :( – sampathsris Sep 8 '15 at 4:28
  • @Krumia I think there is a misunderstanding. Unfortunately, I forgot to mention the main aspect in my last comment: I meant, for example, Chrome's print-to-pdf functionality or the built-in PDF printer of Windows 10. – ComFreek Sep 8 '15 at 7:00
0

You may try WeasyPrint, which converts web documents (HTML with CSS, SVG, …) to PDF. It aims to support web standards for printing.

The source code is available at GitHub.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.