wkhtmltopdf: cannot connect to X server
April 19, 2011
Posted by on
wkhtmltopdf is a useful tool for converting HTML document into PDF. I run it via a cronjob to periodically converting some system reports from HTML format (created by some applications) into PDF. I’m using a Debian (squeeze) version which requires a X11 server, thus the conversion failed (running it from a cronjob does not have access to a X server). Luckily there is a workaround: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=580226 All I need is a virtual X server (
vxfb xvfb) which is available in Debian. Just run it like the following:
vxfb-run xvfb-run wkhtmltopdf ...