How to Convert Webpages to PDF files with Webkit – Wkhtmltopdf

Hello Linux Geeksters.

Watch Free Movies

In this article I will show you how to convert .html files (webpages) to pdf files, by the command line interface.

How to install wkhtmltopdf, on Ubuntu 12.10, Ubuntu 12.04,Ubuntu 11.10, Debian Sid, Debian Wheezy, Debian Squeeze:

$ sudo apt-get install wkhtmltopdf

How to install wkhtmltopdf on Fedora 18 and Fedora 17:

$ sudo yum install wkhtmltopdf

How to install wkhtmltopdf on OpenSUSE 12.3, OpenSUSE 12.2 and OpenSUSE 12.1:

* for 32 bit systems:

$ wget -c

* for 64 bit systems:

$ wget -c

$ sudo zypper install wkhtmltopdf*.rpm

Now that the installation is done, let’s start converting websites to pdf.

Convert site to pdf:

Syntax: wkhtmltopdf name-of-pdf.pdf


$ wkhtmltopdf article.pdf

Convert local html file to pdf:

Syntax: wkhtmltopdf my-file.html my-file.pdf


$ wkhtmltopdf linuxg.html linuxg.pdf

For an easier usage, I have created this function: htmltopdf () { wkhtmltopdf “$@!” ; }

Now, I only have to type htmltopdf and the arguments, instead of wkhtmltopdf and the arguments, which is not easy to remember.

Scroll to Top