0
page 6: warning: no font for Basic Latin character U+000B, fallback to U+2BD1 ⯑
page 6: warning: Ensure fonts are available on the system or load them via a @font-face rule.
page 6: warning: For more information see:
page 6: warning: https://www.princexml.com/doc/help-install/#missing-glyphs-or-fonts
internal error: Unable to find any available fonts.

Hello guys! I'm getting the warnings/errors above when converting HTML to PDF using PrinceXML. In CSS my font is font-family: serif !important;. Because of the error above Prince can't generate a PDF file.

Salim Ibrohimi
  • 1,351
  • 3
  • 17
  • 35

2 Answers2

0

internal error: Unable to find any available fonts.

It appears that the system you're running Prince on does not have any fonts installed. Since this is not usually possible on Windows or macOS systems I imagine you're on a UNIX-like system. I'd suggest installing the Liberation fonts to get started. E.g. fonts-liberation2 package on Debian/Ubuntu.

Wes
  • 2,166
  • 1
  • 20
  • 22
  • Yes, I'm running the Debian Linux distribution. Sorry, forgot to mention that. But I do have the msttcorefonts installed on my server. Most of the time Prince converts HTML to PDF correctly but when some weird Unicode symbols are added I get "no font for Basic Latin character U+000B, fallback to U+2BD1 ⯑" warning and Prince doesn't generate PDF. – Salim Ibrohimi Aug 18 '22 at 07:07
  • Now, I've run Prince with debug option and it seems I do have Liberation fonts on my machine: "Thu Aug 18 07:33:05 2022: debug: font scan: liberation serif, 4 matches". – Salim Ibrohimi Aug 18 '22 at 07:35
  • Hmm that is strange. As you note "no font for Basic Latin character U+000B, fallback to U+2BD1" is a warning and does not prevent Prince from generating a PDF, something else is causing that. It might be worth opening a thread on the Prince Forum and attaching your HTML & CSS to better diagnose the issue. https://www.princexml.com/forum/3/bugs – Wes Aug 19 '22 at 01:53
  • Well, as a workaround, I remove Control Characters (00-1F) from the input string. As my default serif font is Times New Roman and it doesn't support those control characters. Another solution could be to add some font that supports the printing of those said characters. – Salim Ibrohimi Aug 19 '22 at 07:25
0

As I found out Times New Roman is the default serif font in PrinceXML, and it cannot print control characters (0000-000F). So I just remove the control characters from a string before passing it to the PrinceXML as was suggested in this SO question (take a look at the accepted answer).

$string = preg_replace('/[\x00-\x1F\x7F]/u', '', $string);
Salim Ibrohimi
  • 1,351
  • 3
  • 17
  • 35