How to Install wkhtmltopdf on Centos and Ubuntu Server?

Last modified: July 30, 2020
You are here:
Estimated reading time: 1 min

How to Install wkhtmltopdf on Centos and Ubuntu Server?

Wkhtmltopdf is an open-source and effective command-line shell utility that enables the user to convert any given HTML code to PDF document or an image (jpg, png, etc). It helps to print out PDF reports in your server or you will get a warning message saying that you don’t have Wkhtmltopdf while trying to print PDF if you are trying to create PDF without Wkhtmltopdf.

There are two ways to install Wkhtmltopdf.

For Ubuntu:

1) Install the xvfb server by using the below command.

# apt-get install xvfb

For CentOS:

Install all available utilities.

# yum install -y libpng libjpeg openssl icu libX11 libXext libXrender xorg-x11-fonts-Type1 xorg-x11-fonts-75dpi

 

2) Install the latest stable version of wkhtmltopdf from https://bitbucket.org/wkhtmltopdf/wkhtmltopdf/ using the below command.

For Ubuntu:

# wget https://bitbucket.org/wkhtmltopdf/wkhtmltopdf/downloads/wkhtmltox-0.13.0-alpha-7b36694_linux-trusty-amd64.deb

# dpkg -i

# apt-get -f install wkhtmltox-0.13.0-alpha-7b36694_linux-trusty-amd64.deb

Then you need to craete a symbolic link to /usr/local/bin/ unsing the below command.

# echo ‘exec xvfb-run -a -s “-screen 0 640x480x16” wkhtmltopdf “$@”‘ | sudo tee /usr/local/bin/wkhtmltopdf.sh >/dev/null && sudo chmod a+x /usr/local/bin/wkhtmltopdf.sh

For CentOS:

# wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz

# rpm -Uvh wkhtmltox-0.12.4_linux-generic-amd64.tar.xz

OR

unxz wkhtmltox-0.12.4_linux-generic-amd64.tar.xz

tar -xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz

mv wkhtmltox/bin/* /usr/local/bin/

rm -rf wkhtmltox

rm -f wkhtmltox-0.12.4_linux-generic-amd64.tar

 

3) Finally you can check the installation from the below command.

# wkhtmltopdf http://grepitout.com/install-wkhtmltopdf-cpanel-centos/ grepitout.pdf

Loading pages (1/6)

QFont::setPixelSize: Pixel size <= 0 (0)========> ] 79%

QFont::setPixelSize: Pixel size <= 0 (0)

QFont::setPixelSize: Pixel size <= 0 (0)

QFont::setPixelSize: Pixel size <= 0 (0)

Counting pages (2/6)

QFont::setPixelSize: Pixel size <= 0 (0)=====================] Object 1 of 1

QFont::setPixelSize: Pixel size <= 0 (0)

QFont::setPixelSize: Pixel size <= 0 (0)

QFont::setPixelSize: Pixel size <= 0 (0)

QFont::setPixelSize: Pixel size <= 0 (0)

QFont::setPixelSize: Pixel size <= 0 (0)

QFont::setPixelSize: Pixel size <= 0 (0)

Resolving links (4/6)

Loading headers and footers (5/6)

Printing pages (6/6)

QFont::setPixelSize: Pixel size <= 0 (0) ] Preparing

QFont::setPixelSize: Pixel size <= 0 (0)

QFont::setPixelSize: Pixel size <= 0 (0)

QFont::setPixelSize: Pixel size <= 0 (0)=====================] Page 6 of 6

QFont::setPixelSize: Pixel size <= 0 (0)

QFont::setPixelSize: Pixel size <= 0 (0)

Done

If you see Done, then everything is installed correctly

 

You can also verify the wkhtmltopdf by executing the below command.

# wkhtmltopdf -V

wkhtmltopdf 0.12.2.1 (with patched qt)

 

If you need any further assistance please contact our support department.

Was this article helpful?
Dislike 0
Views: 9