elibyy / tcpdf-laravel

TCPDF helper for laravel
MIT License
315 stars 74 forks source link

"Could not include font definition file" when writing HTML tag #102

Closed klaaskox closed 3 years ago

klaaskox commented 3 years ago

I am experiencing a strange problem.

When generating a PDF file, everything works fine in my local development environment. When running the script on a webserver it returns an error: "TCPDF ERROR: Could not include font definition file: roboto" This custom font is loaded with addFont and set with SetFont('roboto', '', 10, '', true);

This error only pops up when I use HTML tags in a string parameter in the writeHTMLCell method

So writing $string='test'; works fine, $string='<b>test</b>'; returns an error.

$this::writeHTMLCell(50, 50, 20, 20, $string, 0, 0, 0, true, 'L', true);

What could be the cause of this problem?

klaaskox commented 3 years ago

Problem solved. I used tcpdf_addfont.php to convert the font files from the .ttf file. I copied these files to my resources/fonts folder, and used this pad in the addFont() method. The error disappeared when I generated the files again and stored them in the /vendor/tecnickcom/tcpdf/fonts/ folder.