April 5, 2012

html to pdf conversion in Linux

To convert html page or an url to pdf, we can use wkhtmltopdf on a linux machine.

Downloaded the relevant static binary v0.10.0 from here: http://code.google.com/p/wkhtmltopdf/downloads/list

via ssh on my shared host typed the following:

wget {relavant url to binary from link above}
tar -xvf {filename of above wget'd file}
For eg: for a 64 bit OS

wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-amd64.tar.bz2
tar -jxvf wkhtmltopdf-0.9.9-static-amd64.tar.bz2
cp -rv wkhtmltopdf-amd64 /usr/local/bin/

Now you can convert pages as follows:

wkhtmltopdf-amd64 http://www.google.com google.pdf

No comments:

Post a Comment