Thursday, April 21, 2016

Opensource PDF generator : wkhtmltopdf

wkhtmltopdf and wkhtmltoimage are open source (LGPLv3) command line tools to render HTML into PDF and various image formats using the Qt WebKit rendering engine. These run entirely "headless" and do not require a display or display service.
There is also a C library, if you're into that kind of thing.
I am writhing this post just to keep record of what actually worked for me - the command I mean.

PATH_TO_wkhtmltopdf\bin\wkhtmltopdf --header-spacing 14 -T 22mm --header-html header.html cover cover.html toc --xsl-style-sheet toc-default.xsl article.html article_to_publish.pdf 
The command above prints a page as pdf with cover page, table of contents and header The TOC layout used is generated using a command as bellow:
PATH_TO_wkhtmltopdf\bin\wkhtmltopdf --dump-default-toc-xsl >> toc-default.xsl
Full document can be found here, which definitely I din find quite qood.