4

We're using wkhtmltopdf in a web project (nodejs/compoundjs). We've gotten it working how we wanted on our machines (using the --use-xserver switch). However, when I try to run this on our Ubuntu server 12.04 (without the ubuntu-desktop package), the PDF cannot use the switch. When we disable the switch, the PDF displays any characters as blocks (image below).

How do I resolve this without installing ubuntu-desktop and running x server?

I've found liberation fonts, which installing ttf-liberation and fonts-liberation did not help. And urw-fonts, but I have yet to find an Ubuntu equivalent.

PDF Output

EDIT: It just hit me, this doesn't matter if I'm on the server or not. On my development machine (Ubuntu 13.04 desktop), I can run the following, which produces the same blocks:

wkhtmltopdf http://google.com google1.pdf

While this prints out the pdf properly:

wkhtmltopdf --use-xserver http://google.com google2.pdf

My version of wkhtmltopdf is 0.12.0.

Martin Thoma
  • 20,535
making3
  • 141

3 Answers3

1

In fact wkhtmltopdf on linux requires quite a lot of Xorg as mentioned on the project page:

(Linux) No longer requires an XServer to be running (however the X11 client libs must be installed)

You should install the client libs as well.

don.joey
  • 29,392
0

If you are using PdfKit on Lambda, you will have to setup ENV variables as:

"FONT_CONFIG_PATH": '/opt/fonts/' 
"FONTCONFIG_FILE": '/opt/fonts/fonts.conf'

Also see: https://stackoverflow.com/questions/46486261/include-custom-fonts-in-aws-lambda

If this problem is in the local environment, a fresh installation of wkhtmltopdf must resolve this.

0

This bug report suggests that wkhtmltopdf just needs whatever xorg-x11-fonts provides:

$ wajig list-installed xfonts
xfonts-base
xfonts-encodings
xfonts-mathml
xfonts-scalable
xfonts-utils

So try installing those. Note that you'll pull in several X dependencies, but not the server itself.

ændrük
  • 78,496