Live data from Hacker News

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

code.google.com

21–30 of 40 posts

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

#21
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.

Why bother with the intermediate stage and not go direct html-to-png?

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

#22

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…

You can work around to the text kerning issue by using custom web-fonts. But I agree, they definitely need to fix this issue.

http://code.google.com/p/wkhtmltopdf/issues/detail?id=72

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

#23
post #20
post #17

Earlier quoted context omitted.

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…

Would it be sufficient to create PNGs of the web pages and extract the text of the webpage to place in the background of a PDF file (for search, screenreading)?

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

#24
Wkhtmltopdf does have its share of warts, but if you need to do a quick and dirty PDF dump of an entire site, it can help.

I used it with wget to scrape a site for conversion: http://darrenknewton.com/blog/2011/10/30/mirror-site-and-con...

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

#25
post #5

Earlier quoted context omitted.

How specifically did you use PhantomJS for PDF generation?

There's an example here: http://code.google.com/p/phantomjs/wiki/QuickStart#Rendering (gives examples of .png and .pdf generation)

Thank you for posting. I recently did a bit of research on producing thumbnails with Ruby using this project: https://github.com/csquared/IMGKit.

Only problem was getting the screenshot to work with Flash. It seems as thought the javascript delay option on wkhtmltopdf didn't delay at all.

Can PhantomJS handle pages with Flash?

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

#26
post #20

Earlier quoted context omitted.

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…

Would it be sufficient to create PNGs of the web pages and extract the text of the webpage to place in the background of a PDF file (for search, screenreading)?

Not for me. Personally I'll stick to ways of making decent PDFs that don't go via HTML.

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

#28

Earlier quoted context omitted.

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.

Why bother with the intermediate stage and not go direct html-to-png?

Originally because I didn't find a free app which would do that. Then I decided to keep the PDF as it was quite useful. Unlike with the PNG, the HTML links were retained in the PDF. Ie, HTML anchor tags are still clickable in PDFs generated by wkhtmltopdf.

EDIT: A PDF will also let you select text, unlike an image. However, an image is nicer to embed in a webpage. So I utilised both in order to get the best of both worlds.

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

#29

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.

If you are not allergic to java, flying-saucer is quite good http://code.google.com/p/flying-saucer/ .

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

#30
post #5

Earlier quoted context omitted.

There's an example here: http://code.google.com/p/phantomjs/wiki/QuickStart#Rendering (gives examples of .png and .pdf generation)

Thank you for posting. I recently did a bit of research on producing thumbnails with Ruby using this project: https://github.com/csquared/IMGKit . Only problem was getting the screenshot to work with Flash. It seems as thought the javascript delay option on wkhtmltopdf didn't delay at all. Can PhantomJS handle pages with Flash?

Not any more, as a web search immediately reveals: http://code.google.com/p/phantomjs/issues/detail?id=418
Post reply on HN