Live data from Hacker News

Wkhtmltopdf, shell utility to convert html to pdf using webkit rendering engine

code.google.com

11–20 of 40 posts

Re: Wkhtmltopdf, shell utility to convert html to pdf using webkit rendering engine

#11
I spent a lot of time 2-3 years ago assessing different tools to convert HTML+CSS to PDF [1]. At the time, this was to convert HTML plus custom tags into well-formatted legal documents.

At the time the hands down winner was Prince XML [2]. It's relatively expensive ($3800 for a single server license) but it just works, works from many languages and produces beautiful results quickly (look at their samples). It doesn't take a lot of developer time to make up that purchase cost.

I haven't checked out this particular project but with the others I have they tended to work for smaller samples but would die, take forever or have unpredictable results on even moderately large documents (~150k).

For any commercial project, honestly I'd just fork over the $3800 for Prince without hesitation. It's simply that good.

EDIT: actually, looking over the SO question I think I did check out an early version of this project and didn't have much success with it. The one thing that concerns me about this project now is the last news item is over a year old. Is it still being actively maintained?

[1]: http://stackoverflow.com/questions/391005/convert-html-css-t...

[2]: http://princexml.com/

Re: Wkhtmltopdf, shell utility to convert html to pdf using webkit rendering engine

#12
It's practically unusable when not in an environment with X11. I had to use it on a Windows system and any text would have incorrect letter-space. Every letter would bleed into the next, it's a typographic nightmare. You could use Arial Unicode MS to get a somewhat acceptable result but that won't support bold or italic text cleanly.

I'm not quite sure but I think the fix isn't even part in the 0.11 release. One has to compile wk himself to get it working.

When this issue is resolved this will be perfect, though. It has great capabilites to render footers and headers and JS-based output (in my case Highcharts). For the time being you can't even switch to commercial systems - ActivePDF, for one, has the same issue in the latest release.

Re: Wkhtmltopdf, shell utility to convert html to pdf using webkit rendering engine

#13

Does anyone know of any other engines like this, either paid or free? We are using this to produce catalogs of 200+ complex pages and it is not handling generating PDFs of this size very well. It will often become unresponsive and create a memory leak.

That seems to be a qt problem, as far as I know. I think a saw somewhere how to recompile qt to get a more robust solution. The issue tracker of wkhtml is quite helpful here.

An easy solution could be to just use extremely short URLs as these seem to affect the space used by wkhtml as well. But that was just my solution for a 200 page output. In addition, if you are using HTML footers or headers, try not to give them any parameters, if possible.

Edit: I can't find the best entry at StackOverflow (I remember there must be a Python based solution as well), but this might be a good overview:

http://stackoverflow.com/questions/633780/converting-html-fi...

Some of those are commercial.

Re: Wkhtmltopdf, shell utility to convert html to pdf using webkit rendering engine

#14
post #11

I spent a lot of time 2-3 years ago assessing different tools to convert HTML+CSS to PDF [1]. At the time, this was to convert HTML plus custom tags into well-formatted legal documents. At the time the hands down winner was Prince XML [2]. It's relatively expensive ($3800 for a single server license) but it just works , works from many languages and produces beautiful results quickly (look at their samples). It doesn…

I used wkhtmltopdf in a previous project and found it to be extremely reliable and easy to use. I was extracting the HTML mime parts from incoming email, converting them to PDFs with wkhtmltopdf, then converting that to a PNG with ImageMagick and displaying the PNG to the user in a web browser.

Re: Wkhtmltopdf, shell utility to convert html to pdf using webkit rendering engine

#15
post #11

I spent a lot of time 2-3 years ago assessing different tools to convert HTML+CSS to PDF [1]. At the time, this was to convert HTML plus custom tags into well-formatted legal documents. At the time the hands down winner was Prince XML [2]. It's relatively expensive ($3800 for a single server license) but it just works , works from many languages and produces beautiful results quickly (look at their samples). It doesn…

Not to mention that Prince XML has excellent support for CSS paged media (margins, page breaks, headers & footers, etc). Contrast with the printed output of any major browser -- they're all quite disappointing.

It would be nice if that $3800 included free upgrades to subsequent releases, though...

Re: Wkhtmltopdf, shell utility to convert html to pdf using webkit rendering engine

#17
post #7

Every time I see a utility like this, I think maybe I could switch to producing some materials in HTML as the primary, or main intermediary, source format. Then I try the utility and realize that that would be silly. For example, I currently make PDF slides for talks. In theory I'd like to make HTML slides, but would still like the ability to render a PDF for a robust record. However, neither this utility (or Phantom…

Well, I am looking for some feedback on a project that converts XML to PDF. Give it a try: https://github.com/kelvin0/PyXML2PDF

Re: Wkhtmltopdf, shell utility to convert html to pdf using webkit rendering engine

#18

Does anyone know of any other engines like this, either paid or free? We are using this to produce catalogs of 200+ complex pages and it is not handling generating PDFs of this size very well. It will often become unresponsive and create a memory leak.

For XHTML to PDF: http://www.xhtml2pdf.com/

For XML to PDF: https://github.com/kelvin0/PyXML2PDF

Re: Wkhtmltopdf, shell utility to convert html to pdf using webkit rendering engine

#19

Does anyone know of any other engines like this, either paid or free? We are using this to produce catalogs of 200+ complex pages and it is not handling generating PDFs of this size very well. It will often become unresponsive and create a memory leak.

I think wkhtmltopdf and PhantomJS are the most active open source solutions.

There's also http://pypi.python.org/pypi/xhtml2pdf/, written in Python and using ReportLab (which certainly has some nice properties).

Re: Wkhtmltopdf, shell utility to convert html to pdf using webkit rendering engine

#20
post #17
post #7

Every time I see a utility like this, I think maybe I could switch to producing some materials in HTML as the primary, or main intermediary, source format. Then I try the utility and realize that that would be silly. For example, I currently make PDF slides for talks. In theory I'd like to make HTML slides, but would still like the ability to render a PDF for a robust record. However, neither this utility (or Phantom…

Well, I am looking for some feedback on a project that converts XML to PDF. Give it a try: https://github.com/kelvin0/PyXML2PDF

I am looking for a command-line utility that could do:

    webpage2pdf 'http://bit-player.org/deck.js/limits-to-growth-Harvard-2012-03-30/ltg-talk.html#Lotka-Volterra' slide.pdf
and actually work (create a sensible PDF representation of what I can see in a browser). So my feedback wouldn't be useful, as my use case is out of scope for your project: "PyXML2PDF is NOT compatible with any XHTML/HTML/CSS. It uses a small set of tags to quickly allow generation of PDFs."
Post reply on HN