You can support us by downloading this article as PDF from the Link below. Download the guide as PDF

In this guide, we will install wkhtmltopdf and wkhtmltoimage on Ubuntu / Debian Linux system. wkhtmltopdf and wkhtmltoimage are open source (LGPLv3) command line tools used to render HTML into PDF and various image formats using the Qt WebKit rendering engine.

The versions of these tools available on Ubuntu / Debian Linux system are old. To get the latest wkhtmltopdf & wkhtmltoimage installed on Debian 10 / Ubuntu 20.04/18.04 Linux, you’ll need to manually download and install from the .deb package. These tools run entirely “headless” and do not require a display or display service.

Install wkhtmltopdf on Ubuntu 20.04/18.04 / Debian 10

Download the latest precompiled binary from the releases page. The latest release as of this article update is 0.12.5.

Install wkhtmltopdf on Ubuntu 20.04/18.04

sudo apt update
sudo apt -y install wget
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb
sudo apt install ./wkhtmltox_0.12.5-1.bionic_amd64.deb

A successful installation output looks like this.

Preparing to unpack .../12-wkhtmltox_0.12.5-1.bionic_amd64.deb ...
Unpacking wkhtmltox (1:0.12.5-1.bionic) ...
Setting up libxrender1:amd64 (1:0.9.10-1) ...
Setting up x11-common (1:7.7+19ubuntu14) ...
update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults
Setting up libfontenc1:amd64 (1:1.1.4-0ubuntu1) ...
Setting up xfonts-encodings (1:1.0.5-0ubuntu1) ...
Setting up fonts-dejavu-core (2.37-1) ...
Setting up libjpeg-turbo8:amd64 (2.0.3-0ubuntu1) ...
Setting up fontconfig-config (2.13.1-2ubuntu3) ...
Setting up xfonts-utils (1:7.7+6) ...
Setting up xfonts-base (1:1.0.5) ...
Setting up libfontconfig1:amd64 (2.13.1-2ubuntu3) ...
Setting up xfonts-75dpi (1:1.0.4+nmu1) ...
Setting up fontconfig (2.13.1-2ubuntu3) ...
Regenerating fonts cache... done.
Setting up wkhtmltox (1:0.12.5-1.bionic) ...
Processing triggers for systemd (245.4-4ubuntu3) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9) ...

Install wkhtmltopdf on Debian 10 / Debian 9

Install wget command line tool.

sudo apt update
sudo apt -y install wget

Install wkhtmltopdf & wkhtmltoimage on Debian 10/9 Linux

--- Debian 10 ---
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.stretch_amd64.deb
sudo apt install ./wkhtmltox_0.12.5-1.stretch_amd64.deb


--- Debian 9 ---
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.stretch_amd64.deb
sudo apt install ./wkhtmltox_0.12.5-1.stretch_amd64.deb

Check the version of wkhtmltopdf and wkhtmltoimage to confirm installation was successful.

$ wkhtmltopdf --version
wkhtmltopdf 0.12.5 (with patched qt)

$ wkhtmltoimage --version
wkhtmltoimage 0.12.5 (with patched qt)

Using wkhtmltopdf on Ubuntu / Debian

For example, if you want to convert a web page as a PDF, use the command syntax:

$  wkhtmltopdf <webpage> <destination-pdf-file>

See below example.

wkhtmltopdf https://computingforgeeks.com computingforgeeks.pdf

Execution output:

A pdf file is created and you can open and view the contents.

$ file computingforgeeks.pdf 
computingforgeeks.pdf: PDF document, version 1.4

The similar syntax applies when converting to image.

$ wkhtmltoimage https://computingforgeeks.com computingforgeeks.png
Loading page (1/2)
QFont::setPixelSize: Pixel size <= 0 (0)=============>       ] 88%
QFont::setPixelSize: Pixel size <= 0 (0)
QFont::setPixelSize: Pixel size <= 0 (0)==============>      ] 89%
QFont::setPixelSize: Pixel size <= 0 (0)
QFont::setPixelSize: Pixel size <= 0 (0)
QFont::setPixelSize: Pixel size <= 0 (0)===============>     ] 90%
QFont::setPixelSize: Pixel size <= 0 (0)
QFont::setPixelSize: Pixel size <= 0 (0)===============>     ] 90%
QFont::setPixelSize: Pixel size <= 0 (0)
QFont::setPixelSize: Pixel size <= 0 (0)===============>     ] 90%
QFont::setPixelSize: Pixel size <= 0 (0)
QFont::setPixelSize: Pixel size <= 0 (0)
QFont::setPixelSize: Pixel size <= 0 (0)===============>     ] 90%
QFont::setPixelSize: Pixel size <= 0 (0)
QFont::setPixelSize: Pixel size <= 0 (0)
QFont::setPixelSize: Pixel size <= 0 (0)===============>     ] 90%
QFont::setPixelSize: Pixel size <= 0 (0)
QFont::setPixelSize: Pixel size <= 0 (0)===============>     ] 90%
QFont::setPixelSize: Pixel size <= 0 (0)=====================] 100%
QFont::setPixelSize: Pixel size <= 0 (0)
Rendering (2/2)                                                    
Done               

Check guides that uses wkhtmltopdf toolkit.

Install Odoo on Debian

Install Odoo on Ubuntu

You can support us by downloading this article as PDF from the Link below. Download the guide as PDF