Skip to content

Generate PDF documents from HTML pages with Web Kit

January 31, 2011

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


From → Web Development

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: