install package “wkhtmltopdf” to convert html to pdf

1. Install the wkhtmltopdf package

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

2. check version

# wkhtmltopdf -V

3. Now link the binary file’

# ln -s /usr/local/bin/wkhtmltopdf /usr/bin/wkhtmltopdf

3. To test whether the html is converted to pdf

# /usr/local/bin/wkhtmltopdf http://www.google.com google.pdf
Loading pages (1/6)
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done

4. To convert the html to pdf using xvfb using following code

xvfb-run –wait=0 wkhtmltopdf -B 20 -L 25 -R 15 -T 20 -q –page-height 300 –page-width 210 -s A4 conv_htmlnPfMsC.html conv_htmlnPfMsC.pdf

You need to install xvfb package.

Install following package with the dependecies

xorg-x11-server-Xvfb.x86_64 0:1.20.4-10.el7

Dependency Installed:
libXdmcp.x86_64 0:1.1.2-6.el7 libXfont2.x86_64 0:2.0.3-1.el7 libxkbfile.x86_64 0:1.0.9-3.el7
xkeyboard-config.noarch 0:2.24-1.el7 xorg-x11-server-common.x86_64 0:1.20.4-10.el7 xorg-x11-xauth.x86_64 1:1.0.9-1.el7
xorg-x11-xkb-utils.x86_64 0:7.7-14.el7

 

Leave a comment