Place the wkhtmltopdf executable on the server and chmod it +x.
Create an executable shell script wrap.sh containing:
#!/bin/sh
export HOME="$PWD"
export LD_LIBRARY_PATH="$PWD/lib/"
exec $@ 2>/dev/null
#exec $@ 2>&1 # debug mode
Download needed shared objects for that architecture and place them an a folder named "lib":
- lib/libfontconfig.so.1
- lib/libfontconfig.so.1.3.0
- lib/libfreetype.so.6
- lib/libfreetype.so.6.3.18
- lib/libX11.so.6 lib/libX11.so.6.2.0
- lib/libXau.so.6 lib/libXau.so.6.0.0
- lib/libxcb.so.1 lib/libxcb.so.1.0.0
- lib/libxcb-xlib.so.0
- lib/libxcb-xlib.so.0.0.0
- lib/libXdmcp.so.6
- lib/libXdmcp.so.6.0.0
- lib/libXext.so.6 lib/libXext.so.6.4.0
(some of them are symlinks)
… and you're ready to go:
./wrap.sh ./wkhtmltopdf-amd64 --page-size A4 --disable-internal-links --disable-external-links "http://www.example.site/" out.pdf
If you experience font problems like squares for all the characters, define TrueType fonts explicitly:
@font-face {
font-family:Trebuchet MS;
font-style:normal;
font-weight:normal;
src:url("http://www.yourserver.tld/fonts/Trebuchet_MS.ttf");
format(TrueType);
}