Thursday, January 8, 2015

How To Use wkhtmltopdf Tool For Windows To Convert HTML to PDF

1. Download wkhtmltopdf from here - http://wkhtmltopdf.org/downloads.html

2. Install it on your Windows machine into C:\Program Files\

3. Open command line prompt

4. Write the command - 'cd progra~1/wkhtmltopdf/bin'. Now you are into the bin directory of wkhtmltopdf.

5. Now write the actual command to convert a HTML file into PDF

$wkhtmltopdf http://www.google.com /.pdf

Please note here that it would not allow the typical windows path like c:\windows.. etc. It will accept path with your IP address or your path like below example.

wkhtmltopdf http://www.google.com \\JohnDow\Users\Public\abc.pdf

Alternatively you can also use forward slashes to access your local drive path from network like below.

wkhtmltopdf http://www.google.com //192.168.0.1/c/xampp/htdocs/test-project/abc.pdf

You can find out your local IP address by firing 'ipconfig' command.

Hope it helps!