Skip to content

Support for wkhtmltopdf

A working solution to add wkhtmltopdf to the existing PHP container is to install it after the container got started:

apk add --no-cache xvfb ttf-freefont fontconfig dbus
apk add qt5-qtbase wkhtmltopdf --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/ --allow-untrusted
mv /usr/bin/wkhtmltopdf /usr/bin/wkhtmltopdf-origin

Then add a new file /usr/bin/wkhtmltopdf with the following content and make it executable:

#!/usr/bin/env sh

Xvfb :0 -screen 0 1024x768x24 -ac +extension GLX +render -noreset &
DISPLAY=:0.0 wkhtmltopdf-origin $@
killall Xvfb

When using the Drupal module print then go to admin/config/user-interface/print/pdf/wkhtmltopdf and remove the options --footer-font-size 7 --footer-right '[page]' because they don't work in the unpatched QT version.

Edited by jurgenhaas