How To Install Wkhtmltopdf (HTML Page To PDF Converter)
To Install Wkhtmltopdf (HTML Page To PDF Converter) in RHEL, CentOS, Fedora
In this article we will learn, how to install Wkhtmltopdf in centos7.
Features
- Options to add headers and footers.
- Open source and cross platform.
- Provides batch mode conversions.
- Table of Content (TOC) generation option.
- Convert any HTML web pages to PDF files using WebKit engine.
- Support for PHP or Python via bindings to libwkhtmltox.
To install Evince (PDF Viewer)
Use the following command to install evince.
[root@linuxhelp ~]# yum install evince
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ftp.iitm.ac.in
* epel: mirror.pregi.net
* extras: ftp.iitm.ac.in
* nux-dextop: li.nux.ro
* updates: ftp.iitm.ac.in
Resolving Dependencies
--> Running transaction check
---> Package evince.x86_64 0:3.14.2-5.el7 will be installed
--> Finished Dependency Resolution
..
..
Total download size: 2.3 M
Installed size: 9.0 M
Is this ok [y/d/N]: y
Downloading packages:
evince-3.14.2-5.el7.x86_64.rpm | 2.3 MB 00:17
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : evince-3.14.2-5.el7.x86_64 1/1
Verifying : evince-3.14.2-5.el7.x86_64 1/1
Installed:
evince.x86_64 0:3.14.2-5.el7
Complete!
To Download Wkhtmltopdf Source File
On RHEL/CentOS/Fedora 32-bit OS
Use the following command to download Wkhtmltopdf.
wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.10.0_rc2-static-i386.tar.bz2
On RHEL/CentOS/Fedora 64-bit OS
Use the following command to download Wkhtmltopdf.
[root@linuxhelp ~]# wget https://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.10.0_rc2-static-amd64.tar.bz2
--2016-04-02 14:32:17-- https://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.10.0_rc2-static-amd64.tar.bz2
Resolving wkhtmltopdf.googlecode.com (wkhtmltopdf.googlecode.com)... 74.125.200.82, 2404:6800:4003:c00::52
Connecting to wkhtmltopdf.googlecode.com (wkhtmltopdf.googlecode.com)|74.125.200.82|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10995568 (10M) [application/x-bzip2]
Saving to: ‘ wkhtmltopdf-0.10.0_rc2-static-amd64.tar.bz2’
100%[======================================> ] 10,995,568 175KB/s in 51s
2016-04-02 14:33:10 (209 KB/s) - ‘ wkhtmltopdf-0.10.0_rc2-static-amd64.tar.bz2’ saved [10995568/10995568]
To Install Wkhtmltopdf
Use the following command to extract files to directory like, opt.
For RHEL/CentOS/Fedora 64-Bit OS
[root@linuxhelp ~]# tar -xvf wkhtmltopdf-0.10.0_rc2-static-amd64.tar.bz2 -C /opt/
wkhtmltopdf-amd64
Install the wkhtmltopdf to the directory /usr/local/bin for easy execution of program from any path.
For RHEL/CentOS/Fedora 64-Bit OS
[root@linuxhelp ~]# cd /opt/ [root@linuxhelp opt]# ls -l total 10812 -rwxr-xr-x. 1 user1 user1 11068596 Jan 30 2011 wkhtmltopdf-amd64 [root@linuxhelp opt]# mv wkhtmltopdf-amd64 wkhtmltopdf [root@linuxhelp opt]# ls -l total 10812 -rwxr-xr-x. 1 user1 user1 11068596 Jan 30 2011 wkhtmltopdf [root@linuxhelp opt]# mv wkhtmltopdf /usr/local/bin/
Uses of Wkhtmltopdf
To Convert Remote HTML Page to PDF File
Run the following command to convert any HTML web page to PDF and it will convert the given webpage to linuxhelp.pdf as output to /opt directory.
[root@linuxhelpopt]# wkhtmltopdf http://onlinesignature.netaxisstudio.com/fancy-signature.html /opt/linuxhelp.pdf
Loading pages (1/6)
QSslSocket: cannot call unresolved function SSLv3_client_method58%
QSslSocket: cannot call unresolved function SSL_CTX_new
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function ERR_get_error
..
..
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done
To View Generated PDF File
Run the following command, to verify that the file is created.
[root@linuxhelp opt]# file /opt/linuxhelp.pdf
/opt/linuxhelp.pdf: PDF document, version 1.4
To view Information of Generated PDF File
Run the following command, to view the information of generated file.
[root@linuxhelp opt]# pdfinfo /opt/linuxhelp.pdf
Title: Fun and Fancy Signature Creator Online: OnlineSignature.in
Creator:
Producer: wkhtmltopdf
CreationDate: Mon Apr 4 09:14:38 2016
Tagged: no
UserProperties: no
Suspects: no
Form: none
JavaScript: no
Pages: 3
Encrypted: no
Page size: 595 x 842 pts (A4)
Page rot: 0
File size: 123280 bytes
Optimized: no
PDF version: 1.4
To view Created PDF File
Run the following command to view the created file.
[root@linuxhelp opt]# evince /opt/linuxhelp.pdf
To Create TOC (Table of Content) of a Page to PDF
Use the following command to create a table of content for a PDF file.
[root@linuxhelp opt]# wkhtmltopdf http://onlinesignature.netaxisstudio.com/fancy-signature.html /opt/linuxhelp1.pdf
Loading pages (1/6)
QSslSocket: cannot call unresolved function SSLv3_client_method60%
QSslSocket: cannot call unresolved function SSL_CTX_new
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function ERR_get_error
..
..
Counting pages (2/6)
Loading TOC (3/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done
To view the toc pdf file
[root@linuxhelp opt]# evince /opt/linuxhelp1.pdf
(evince:8999): EggSMClient-WARNING **: Failed to connect to the session manager: None of the authentication protocols specified are supported
Comments ( 1 )