You are here

Convert HTML to PDF using wkhtmltopdf

wkhtmltopdf is an excellent utility for converting an URL or HTML file to PDF. Kindly note that the current version of wkhtmltopdf in Debian, as of today, is 0.9.9, which is outdated. I highly recommend that you download the latest featured version from and use it instead. Here are some examples for using wkhtmltopdf.

Simple conversion of html to pdf.

# wkhtmltopdf google.pdf
# wkhtmltopdf input.html output.pdf

Input and output files could be replaced with standard input and standard output.

# cat input.html | wkhtmltopdf - - > output.pdf

Disabling PDF outline (versions prior to 0.10.0 had outline disabled by default).

# wkhtmltopdf --no-outline input.html output.pdf

Adding a custom header and footer.

# wkhtmltopdf --header-left "Some header text" --footer-center "Some footer text" input.html output.pdf




I just went through this post and found it really informative. Earlier I didn't know about this code for HTML to PDF conversion. I was only aware of tools that can convert into HTML to PDF.

There are multiple tools and online applications available to convert into any desired format. Now, it's up to you whether to use these tools, or use this conversion with the help of code.

I learned a new way of conversion through this post. Thanks :)

Add new comment