“wkhtmltopdf and wkhtmltoimage are open source (LGPL) command line tools to render HTML into PDF and various image formats using the QT Webkit rendering engine. These run entirely “headless” and do not require a display or display service.” Source: http://wkhtmltopdf.org/
There are two options:
- standard: fewer features, requires X (and if your ClearOS is virtualized, it perhaps won't work)
- patched QT: more features, doesn't require X (headless)
How to install wkhtmltopdf patched QT on ClearOS
- Get the URL of the last stable version from the wkhtmltopdf download page
- Attempt to install
rpm -Uvh wkhtmltox-0.12.2.1_linux-centos6-amd64.rpm
- The system will likely report missing dependencies. Just add them with the following (and try again to install)
yum --enablerepo=clearos-core install PUTNAMEOFDEPENDENCYHERE
- To test
wkhtmltopdf http://wkhtmltopdf.org/ wkhtmltopdf-test.pdf
- To know what “WebKit path” to provide to your web app (ex.: Tiki)
which will report something like:
How to install wkhtmltopdf on ClearOS
Experimental. Unless you know what you are doing, use the patched QT option above
The qtwebkit version is useful to check when there is a bug:
- CentOS / ClearOS 6: 2.1.1
- CentOS / ClearOS 7: 2.3.3
1.- Login to your ClearOS via SSH.
2.- Make sure epel-release in an active repo
rpm -ivh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm?
3.- Activate ClearOS core repo
# In the marketplace (https://example.org:81/app/marketplace), activate the "Software Repository" app # https://example.org:81/app/software_repository # click "Detailed view" # Click "Toggle" on the clearos-core line
4.- Enable Okay.com.mx repository by running rpm accordingly:
For 32 bits:
rpm -ivh http://repo.okay.com.mx/centos/6/i386/release/okay-release-1-1.noarch.rpm?
For 64 bits:
rpm -ivh http://repo.okay.com.mx/centos/6/x86_64/release/okay-release-1-1.noarch.rpm?
yum install wkhtmltopdf
once yum finishes the dependency Resolution it will show you a summary and will ask you to confirm.
6.- Confirm with y, yum will download and install the required rpms and will inform o the completion.
7.-Install the Xvfb (X Virtual Frame Buffer) type:
yum install xorg-x11-server-Xvfb
and confirm installation with “y” and wait for completion.
8.- To use, include within the xvfb execution: Example:
xvfb-run --server-args="-screen 0, 1024x768x24" wkhtmltopdf http://google.com google.pdf__
Output is visible with any reader application.
9- Make a wkhtmltopdf.sh to simplify Create a file /usr/local/bin/wkhtmltopdf.sh containing the following“
xvfb-run -a -s "-screen 0 1024x768x24" wkhtmltopdf "$@"
Using the command
wkhtmltopdf.sh http://tiki.org tiki.pdf
as WebKit path in the tiki administration page