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. wkhtmltopdf is able to put several objects into the output file, an object is
either a single webpage, a cover webpage or a table of contents.

The objects are put into the output document in the order they are specified on the command line, options can be specified on a per object basis or in the global options area. In this blog post you’ll learn to install wkhtmltopdf & wkhtmltoimage on CentOS 8 | CentOS 7 Linux machine.

Install wkhtmltopdf and wkhtmltoimage on CentOS

The binary packages of wkhtmltopdf are provided for CentOS 8 and CentOS 7. These packages are available in the software downloads section.

Install wget which we’ll use to download wkhtmltopdf RPM package on CentOS 8 | CentOS 7:

sudo yum -y install wget

Install wkhtmltopdf on CentOS 8:

Download the software package with wget or curl.

wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.centos8.x86_64.rpm

Install with rpm or yum package management tools.

sudo dnf localinstall wkhtmltox-0.12.6-1.centos8.x86_64.rpm

A number of dependencies are installed.

...
Transaction Summary
==================================================================================================================================================================
Install  21 Packages

Total size: 22 M
Total download size: 6.6 M
Installed size: 139 M
Is this ok [y/N]: y

Install wkhtmltopdf on CentOS 7:

Download the RPM package of wkhtmltopdf:

wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.centos7.x86_64.rpm

Then install wkhtmltopdf on CentOS 7 by executing the following commands:

sudo yum localinstall wkhtmltox-0.12.6-1.centos7.x86_64.rpm

Confirm software versions installed.

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

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

Convert web page to pdf:

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

More interesting articles available in our website.

LEAVE A REPLY

Please enter your comment!
Please enter your name here