html to pdf including the css

.. because I wasted way to much time on finding easiest way to convert an html file to pdf , including the css :

1. On apt based Linux, install wkhtmltopdf and its dependencies :
sudo apt-get install wkhtmltopdf

2. Usage:

To convert a remote HTML file to PDF:
wkhtmltopdf http://www.google.com google.pdf

To convert a local HTML file to PDF:
wkhtmltopdf my.html my.pdf

You can also convert to PS files if you like:
wkhtmltopdf my.html my.ps

The eler2.pdf sample file
wkhtmltopdf http://geekz.co.uk/lovesraymond/archive/eler-highlights-2008 eler2.pdf -H --outline

source: http://code.google.com/p/wkhtmltopdf/wiki/Usage

Creator/maintainer has also recently created some PHP bindings for this as well. More on this version at http://blog.perplexedlabs.com/2010/09/15/convert-html-to-pdf-in-php-libwkhtmltox-extension/

This entry was posted in Linux, Ubuntu, WebTechnology. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>