wkhtmltopdf is an excellent opensource tool for converting html to PDF or an Image like JPEG, PNG etc.. It is available under GNU/GPL and written in C++ programming language. It can convert any HTML web page to PDF with Options to add Header and Footer. Also with Table of Content writing Option. It is available for both 32 and 64 bit Linux systems.
For dowloading 32bit tool use the below command.
# wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.11.0_rc1-static-i386.tar.bz2
For downloading 64bit tool use the below command.
# wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.11.0_rc1-static-amd64.tar.bz2
Extract the Files:
# tar -xvf wkhtmltopdf-0.11.0_rc1-static-amd64.tar.bz2 -C /opt
Install the wkhtmltopdf under /bin directory for easy execution of program from any path.
# cd /opt # mv wkhtmltopdf-amd64 /bin # cd /bin # mv wkhtmltopdf-amd64 wkhtmltopdf
To verify the installation issue the below command
# wkhtmltopdf http://www.google.com/ google-test.pdf
The output will look like this:
Loading pages (1/6) Counting pages (2/6) Resolving links (4/6) Loading headers and footers (5/6) Printing pages (6/6) Done