3

I have a problem generating invoices on CiviCRM-4.6.16 with wkhtmltopdf-0.11.0_rc1 on Drupal (7.43).

In the template I define a font-family

@font-face {
font-family:LiberationSans-Regular;
src:
url(/ABSOLUTE/PATH/TO/fonts/LiberationSans-Regular.ttf);}

In the Body I define a table I want to use the font like this:

      <table style = "padding-right:19px;font-family:LiberationSans-Regular;" width = "500" height = "100" border = "0" cellpadding = "2" cellspacing = "1">

The font is always ignored, except when I use a system/default font (e.g. Courier).

I tried numerous locations on where to put the fonts, since I suspected a permission problem or something like that, but apparently nothing helps and I can't get other fonts in the pdf export.

I verified that wkhtmltopdf is used (via meta data of the pdf).

Help would be appreciated!

  • If you inspect your webserver logs, do you see wkhtmltopdf make requests for font files at the locations you expect while requesting and rendering the invoice HTML? Filesystem permissions shouldn't be an issue since wkhtmltopdf would be requesting the files over the network, just like any other browser. So may be worthwhile confirming that this behaviour matches what you see for "normal" desktop browsers. – Chris Burgess Jan 15 '17 at 22:55
  • This related SE question/answer suggests that wkhtmltopdf 0.11.x has/had issues resolving relative URLs in fonts? – Chris Burgess Jan 15 '17 at 23:01
1

Another option to try is to use inline fonts encoded in the base64 format. This prevents file system permission problems. More information can be found in this blog entry.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.