Steps to install wkhtmltopdf in Centos 7 Redhat

Steps to install wkhtmltopdf in Centos 7 Redhat Linux


As you may know, wkhtmltopdf is a tool that is used to create a pdf on the fly from the Linux/Unix shell from any html document. You are probably running Centos 7 Redhat on (AWS) Amazon EC2 server. Outlined here are the simple steps on how to install.

Step 1 is to create a html document
Step 2 is to call wkhtmltopdf with the html document as input and pdf as output

But, before that, we need to install wkhtmltopdf in the Linux server machine.

Install wkhtmltopdf in Centos 7

Before we install wkhtmltopdf, we need to install the dependencies or support packages, which are required for wkhtmltopdf to work as expected.

So, we execute the following steps.

i. sudo yum install -y xorg-x11-fonts-75dpi
ii. sudo yum install -y xorg-x11-fonts-Type1

Let us get the rpm package from the link gna.org using the link below.
wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-centos7-amd64.rpm

sudo rpm -Uvh wkhtmltox-0.12.2.1_linux-centos7-amd64.rpm

error: Failed dependencies:
        libXext is needed by wkhtmltox-1:0.12.2.1-1.x86_64
        libXrender is needed by wkhtmltox-1:0.12.2.1-1.x86_64

As you can see, there are two libraries that are missing. Let us install them too.


Install dependencies libXext libXrender for wkhtmltopdf


iii. sudo yum install libXext libXrender

Loading mirror speeds from cached hostfile
 * base: mirror.web-ster.com
 * epel: mirrors.cat.pdx.edu
 * extras: mirrors.xmission.com
 * updates: centos.eecs.wsu.edu
Resolving Dependencies
--> Running transaction check
---> Package libXext.x86_64 0:1.3.3-3.el7 will be installed
---> Package libXrender.x86_64 0:0.9.8-2.1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved



Installing:
 libXext                                  x86_64                               1.3.3-3.el7                                    base                                39 k
 libXrender                               x86_64                               0.9.8-2.1.el7                                  base                                25 k



Install  2 Packages

Total download size: 64 k
Installed size: 127 k
Is this ok [y/d/N]: y
Downloading packages:
(1/2): libXrender-0.9.8-2.1.el7.x86_64.rpm                                                                                                      |  25 kB  00:00:00
(2/2): libXext-1.3.3-3.el7.x86_64.rpm                                                                                                           |  39 kB  00:00:00

Finally, let us try installing the rpm package again.

iv. sudo rpm -Uvh wkhtmltox-0.12.2.1_linux-centos7-amd64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:wkhtmltox-1:0.12.2.1-1           ################################# [100%]

We have successfully set up and installed wkhtmltopdf on our machine.

Now, let us test if the module is working. We will try to create a pdf document  out of Google's first page.

wkhtmltopdf https://www.google.com google.pdf

No comments:

Why is there poverty and suffering in the world?

Poverty and Suffering in the World Poverty and suffering is pointed out by the atheists to prove that God does not exist.  Before w...

Copyrighted.com Registered & Protected DWYE-NHTO-NBNH-7FFM