Install wkhtmltopdf and wkhtmltoimage on Ubuntu 18.04 / Debian 10 Linux

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

These tools are outdated versions available on Ubuntu / Debian Linux systems. To get the latest wkhtmltopdf and wkhtmltoimage installed on Debian 10 / Ubuntu 18.04 Linux, you need to download and install manually from .deb package. These tools run completely “headless” and do not require display or display services.

Install wkhtmltopdf on Ubuntu 18.04 / Debian 10

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

Install wkhtmltopdf on Ubuntu 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 dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb
sudo apt -f install

The output of a successful installation is shown below.

(Reading database … 172496 files and directories currently installed.)
Preparing to unpack wkhtmltox_0.12.5-1.bionic_amd64.deb …
Unpacking wkhtmltox (1:0.12.5-1.bionic) over (1:0.12.5-1.bionic) …
Setting up wkhtmltox (1:0.12.5-1.bionic) …
Processing triggers for man-db (2.8.3-2ubuntu0.1) …

Install wkhtmltopdf on Debian 10 / Debian 9

For Debian 9, run the command.

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

Check the versions of wkhtmltopdf and wkhtmltoimage to confirm successful installation.

$ 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 to PDF, use the following command syntax:

$  wkhtmltopdf  

See the example below.

wkhtmltopdf https://computingforgeeks.com computingforgeeks.pdf

Execution output:

Install wkhtmltopdf and wkhtmltoimage on Ubuntu 18.04 / Debian 10 Linux

A pdf file will be created and you can open and view its contents.

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

When converting to an image, a similar syntax is applied.

$ 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 the guide for using the wkhtmltopdf toolkit.

Install Odoo on Debian

Install Odoo on Ubuntu

Sidebar