Wkhtmltopdf is a command line utility for converting webpage / html to PDF.
Features
- Convert web pages into PDF documents using webkit
- Adding headers and footers (static version only)
- TOC generation (static version only)
- Batch mode conversions
- (Linux) No longer requires an XServer to be running (however the X11 client libs must be installed)
How to install wkhtmltopdf in Ubuntu / Debian
$ sudo apt-get install wkhtmltopdf
Usage:
$ wkhtmltopdf –help
This will provide help for using wkhtmltopdf
If you want to Convert website home page to a PDF document
$ wkhtmltopdf www.keralalinux.com keralalinux.pdf
This will convert the home page of www.keralalinux.com to a file named keralalinux.pdf.
Page orientation can be change using -O option
$ wkhtmltopdf -O Landscape www.keralalinux.com keralalinux.pdf
This will change page orientation to landscape
Page size can be change using -s option
$ wkhtmltopdf -s A4 www.keralalinux.com keralalinux.pdf
This will change page size to a4 it will support A4, letter etc.
Add table of contents to the pdf document with -t option
$ wkhtmltopdf -t www.keralalinux.com keralalinux.pdf