Thursday, 28 November 2013

Convert html to pdf on Fedora

wkhtmltopdf is a linux program that convert a webpage(html) to pdf format. The installation instruction of wkhtmltopdf are as below.
yum install wkhtmltopdf
To convert, simply enter as below:
wkhtmltopdf http://google.com test.pdf
However it will errored as it needs a X server:
wkhtmltopdf: cannot connect to X server
To solve the problem, we can install:
yum install xorg-x11-server-Xvfb
Create a shell script as below:
vi wkhtmltopdf.sh
And save with these parameters:
xvfb-run -a -s "-screen 0 640x480x16" wkhtmltopdf $*
And this is the way to run in commandline
wkhtmltopdf.sh http://www.google.com test.pdf

1 comment :

  1. Why can nobody write a program that i as windows idiot can install easy all programs with out to write su bla blab password bla bla. Trough this bad system can LINUX et. not on the market win !!!

    a@octonet.org

    ReplyDelete

search iomeweekly