Generate PDF documents from HTML pages with Web Kit
Use wkhtmltopdf to generate PDFs of your web pages.
A frequent need we have is to be able generate PDF documents from our website content. A savvy user can always use a print-driver based solution like PrimoPDF to print a web page out to PDF but that’s not really user friendly. There are also PDF creation libraries that allow you to programmatically generate PDF output but from my experience they can only generate very basic looking output (and only with a lot of work).
That leads me to the best solution we’ve found from both user and developer standpoints.
Simple shell utility to convert html to pdf using the webkit rendering engine, and qt.
Using this tool, creating a PDF from a website is as simple as running the following at a command prompt:
wkhtmltopdf http://www.myhomepage.com myhomepage.pdf
wkhtmltopdf is a great little piece of software engineering that takes advantage of the Web Kit HTML rendering engine to render web pages and capture the output as PDF. Web Kit is the open source rendering engine that powers the display of the Google Chrome and Safari web browsers. wkhtmltopdf uses webkit in the form of the QTWebKit widget that was released with QT 4.4. If you’ve ever tried working with the Web Kit codebase you’ll know that using the QT wrapper is a huge productive booster.
For Drupal people, there’s print module that can be configured to utilize this library to create PDF versions of content.