How to run wkhtmltopdf
headless?!
Installation on Debian Whezzy
apt-get install wkhtmltopdf
Command
wkhtmltopdf --title "$SUBJECT" -q $SOURCEFILE $OUTPUTFILE
Error
QXcbConnection: Could not connect to display
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityThere is a more easy way to make John WH Smith solution.
Just install xvfb from apt and then, you can run:
xvfb-run wkhtmltopdf
(just put xvfb-run
before any wkhtmltopdf command.)
sudo apt-get install xauth
and try again!
Aug 18, 2016 at 14:49
xvfb-run
command in CentOS: yum install xorg-x11-server-Xvfb
This is a bug, and the fix hasn't been brought to the Debian repositories. Quoting ashkulz (who closed the bug report) :
You're using the version of wkhtmltopdf in the debian repositories, which does not support running headless.
So you can either...
wkhtmltopdf
from source and compile it (see the instructions in the INSTALL.md file ; you may remove the --recursive
option from their git clone
line, if you already have Qt 4.8 installed).xvfb
, as suggested by masterkorp in the bug report.phantomjs /usr/share/doc/phantomjs/examples/rasterize.js $url $pdf
.
/var/bin/wkhtmltopdf
.. cd /var/bin/wkhtmltopdf && scripts/build.py wheezy-amd64
=> -bash: scripts/build.py: Permission denied
/var/bin
. Take it to your home directory and follow the instructions in the INSTALL.md
file, for your distribution.
Mar 26, 2015 at 13:39
on your command line type like this
export DISPLAY=:0
then run your qt
applications
.tar.xz
file from the GitHub release page and copy the binary fromwkhtmltox/bin/wkhtmltopdf
to/usr/bin/
. [from here]