Skip to content

Instantly share code, notes, and snippets.

@danilodorgam
Last active June 6, 2018 14:19
Show Gist options
  • Save danilodorgam/268a010643a740fdda8314dc8a7aea06 to your computer and use it in GitHub Desktop.
Save danilodorgam/268a010643a740fdda8314dc8a7aea06 to your computer and use it in GitHub Desktop.
wkhtmltopdf centos 7 headless with xvfb

wkhtmltopdf centos 7 headless with xvfb

Install and run standalone Xvfb

yum install xorg-x11-server-Xvfb
yum install xorg-x11-fonts-Type1 xorg-x11-fonts-75dpi
wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-centos7-amd64.rpm
rpm -ivh wkhtmltox-0.12.2.1_linux-centos7-amd64.rpm
sudo ln -s /local/onde/ta/o/wkhtmltox/bin/wkhtmltopdf /usr/bin/
vim xvfb.service
cp xvfb.service /etc/systemd/system/xvfb.service
sudo systemctl enable xvfb.service
sudo systemctl start xvfb.service
sudo systemctl status xvfb.service

sudo systemctl daemon-reload

vim wkhtmltopdf.sh
chmod a+rx wkhtmltopdf.sh
./wkhtmltopdf.sh http://www.google.com output.pdf

Refs

xvfb-run -a -s "-screen 0 1024x768x24" wkhtmltopdf "$@"
[Unit]
Description=Virtual Frame Buffer X Server
After=network.target
[Service]
ExecStart=/usr/bin/Xvfb :42 -screen 0 1024x768x24 -ac +extension GLX +render -noreset
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment