UTF-8 problem (FontLib\\Table\\Type\\fftm not found)

202 views
Skip to first unread message

Tamás Bulyáki

unread,
Oct 25, 2020, 3:56:03 AM10/25/20
to dompdf
Hey,

I ran into this error and many others while was trying to generate pdf from a few different html inputs.

I'm on a blockly project and this is from where the html sources are coming.

I have to use UTF-8 output and when I try to use the builtin Dejavu fonts I got the errors below (with some cpdf debug message) and the pdf is not generated. I'm on windows and I have a linux server as well to test the results and got the same problem there - not counting that on linux there were more missing table type errors.

The only workaround I found yet is to force to use some already known table type by adding these to the File.php in php-font-lib/src/FontLib/TrueType:

I tried first to create manually these empty classes to avoid the error, but when I figured out all the missing classes and it worked finally on windows it turned out that on linux were more other missing classes - so I gave up and simply ignored all the unknown types.

What do I miss - I have a feeling that I'm doing something wrong - but there are simply no matches when I try to google it for this kind of error.

Thanks in advance for any input an help!


[Sun Oct 25 08:14:56.449926 2020] [php7:notice] [pid 26780:tid 1820] [client ::1:50646] selectFont: selecting - C:\\xampp\\htdocs\\snap\\SNAP\\vendor\\dompdf/lib/fonts/DejaVuSerif - , 1\nopenFont: C:\\xampp\\htdocs\\snap\\SNAP\\vendor\\dompdf/lib/fonts/DejaVuSerif - DejaVuSerif\nmetrics: DejaVuSerif.ufm, cache: DejaVuSerif.ufm.php\nopenFont: php file exists C:\\xampp\\htdocs\\snap\\SNAP\\vendor\\dompdf/lib/fonts/DejaVuSerif.ufm.php\nselectFont: selecting - C:\\xampp\\htdocs\\snap\\SNAP\\vendor\\dompdf/lib/fonts/DejaVuSerif-Bold - , 1\nopenFont: C:\\xampp\\htdocs\\snap\\SNAP\\vendor\\dompdf/lib/fonts/DejaVuSerif-Bold - DejaVuSerif-Bold\nmetrics: DejaVuSerif-Bold.ufm, cache: DejaVuSerif-Bold.ufm.php\nopenFont: php file exists C:\\xampp\\htdocs\\snap\\SNAP\\vendor\\dompdf/lib/fonts/DejaVuSerif-Bold.ufm.php\nselectFont: checking for - C:\\xampp\\htdocs\\snap\\SNAP\\vendor\\dompdf/lib/fonts/DejaVuSerif.ttf\n, referer: https://localhost/snap/SNAP/snut/get_page.php?page_id=7357852355104343&panel=M
[Sun Oct 25 08:14:56.455779 2020] [php7:notice] [pid 26780:tid 1820] [client ::1:50646] [snap] [error FontLib\\Table\\Type\\fftm not found] [pid 26780] [url /snap/SNAP/repo03/mapper/process.php] [username nev****ind] [userid 7595783275122354] [pageid -] [pagename -] [processid 7377862355104091] [details {"class":"RuntimeException"}] [stack [{"function":"{closure}","args":["FontLib\\\\Table\\\\Type\\\\fftm"]},\r\n{"function":"spl_autoload_call","args":["FontLib\\\\Table\\\\Type\\\\fftm"]},\r\n{"file":"C:\\\\xampp\\\\htdocs\\\\snap\\\\SNAP\\\\vendor\\\\dompdf\\\\lib\\\\php-font-lib\\\\src\\\\FontLib\\\\TrueType\\\\File.php","line":312,"function":"class_exists","args":["FontLib\\\\Table\\\\Type\\\\fftm"]},\r\n{"file":"C:\\\\xampp\\\\htdocs\\\\snap\\\\SNAP\\\\vendor\\\\dompdf\\\\lib\\\\php-font-lib\\\\src\\\\FontLib\\\\TrueType\\\\File.php","line":124,"function":"readTable","class":"FontLib\\\\TrueType\\\\File","type":"->","args":["FFTM"]},\r\n{"file":"C:\\\\xampp\\\\htdocs\\\\snap\\\\SNAP\\\\vendor\\\\dompdf\\\\lib\\\\Cpdf.php","line":1170,"function":"parse","class":"FontLib\\\\TrueType\\\\File","type":"->","args":[]},\r\n{"file":"C:\\\\xampp\\\\htdocs\\\\snap\\\\SNAP\\\\vendor\\\\dompdf\\\\lib\\\\Cpdf.php","line":931,"function":"processFont","class":"Dompdf\\\\Cpdf","type":"->","args":[8,{"name":"DejaVuSerif","fontFileName":"C:\\\\xampp\\\\htdocs\\\\snap\\\\SNAP\\\\vendor\\\\dompdf\\/lib\\/fonts\\/DejaVuSerif","SubType":"Type1","isSubsetting":true,"fontNum":1,"encoding":"WinAnsiEncoding","toUnicode":9,"cidFont":10}]},\r\n{"file":"C:\\\\xampp\\\\htdocs\\\\snap\\\\SNAP\\\\vendor\\\\dompdf\\\\lib\\\\Cpdf.php","line":3198,"function":"o_font","class":"Dompdf\\\\Cpdf","type":"->","args":[8,"add"]},\r\n{"file":"C:\\\\xampp\\\\htdocs\\\\snap\\\\SNAP\\\\vendor\\\\dompdf\\\\src\\\\Adapter\\\\CPDF.php","line":1213,"function":"output","class":"Dompdf\\\\Cpdf","type":"->","args":[false]},\r\n{"file":"C:\\\\xampp\\\\htdocs\\\\snap\\\\SNAP\\\\vendor\\\\dompdf\\\\src\\\\Dompdf.php","line":932,"function":"output","class":"Dompdf\\\\Adapter\\\\CPDF","type":"->","args":[{"compress":true}]},\r\n{"file":"C:\\\\xampp\\\\htdocs\\\\snap\\\\SNAP\\\\repo03\\\\report_utils.php","line":182,"function":"output","class":"Dompdf\\\\Dompdf","type":"->","args":[]},\r\n{"file":"C:\\\\xampp\\\\htdocs\\\\snap\\\\SNAP\\\\repo03\\\\mapper\\\\process.php(66) : eval()'d code","line":8,"function":"PDFwithAttachment","args":["<style>\\r\\n        input[type=text]:before { border: 1px solid #FFF; }\\r\\n        label { display: block; padding-bottom: 2px; }\\r\\n        <\\/style>\\r\\n        <html> <head> <title><\\/title> <\\/head> <body> <h3>Tervez&eacute;s &gt; M\\u0171k&ouml;d&eacute;s&nbsp;&gt;&nbsp;Blockly language&nbsp;<\\/h3>  <h1>Frames<\\/h1>  <p>Eml&eacute;keztet\\u0151&uuml;l: a b&ouml;ng&eacute;sz\\u0151 ablakot a SNAP keretekre &ndash; frame &ndash; osztja fel: top, left, middle, right, bottom.<\\/p>  <p>A keretekkel v&eacute;gezhet\\u0151 m\\u0171veletek blokkjait a Event Blocks \\/ Frames men&uuml;ben tal&aacute;ljuk.<\\/p>  <p>&nbsp;<\\/p>  <p><img src=\\"data:image\\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQcAAACDCAYAAACA\\/d7dAAAgAElEQVR4Ae2dB3hdxZn3f6fcqqsuWb1a7sYNF8DYQHAgkJAEvpCyy6aQwkJINiTf5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\/EyUwqN1nxs3d4a+lm9AsmMmNiarJTeH+iioIZ6aanI5+bbn2Yf73pUjr2b2D2l+7l7ps\\/z871uzgUjyHW47XvXc2v11nceuf93H\\/LP1CephHXo6x+9gns4i9y\\/48e4uuXz0IJxbER3pKPeMtqnlv1ChOv\\/Cw33\\/g5JhxcwdJnlmN4fY6X6pgjhp+4Sc8NYDUH6elQSMsJoDmpvN\\/g5HdF10hsr2f\\/th5C+\\/axb0U93iwPh598j\\/XP7uXwu3WseHQtW\\/+8k0MHo+ROLCcjxY3a3s2O+95hy8s9lF7sofr3K1izro2MgnJKLh9P1QIf9X\\/ewfYXa9DnTmfGpyowY33dxcC2\\/DV7B\\/AchpacACy8BF+mzzEw3hN3xtxCQcXwQjTeY27SoSXrnOVy5aCEmmlp6EJPKOyrbqe80IvftFEWTWXeNA+RToV4yCbNn4l1+F26ggoq7XR2xo5djCliIsEI7U1BTD1OR\\/UB+FgZilZP9qz5zJ7rpqvW5TTC\\/IoUou+2Yhgmsd0ddO0NQ54YerhR9EwmfiYHlB72v9xKNBljOz74aJqYqdmMnzENX6yTsJZOuqebxuZqZlbOY5


Here are my dompdf settings, actually the whole function:

function PDFwithAttachment($aPDFcontent, $aPDFattachments) {
//set dompdf options
$options = new Options();
$options->set('defaultFont', 'dejavu serif, serif');
$options->setIsHtml5ParserEnabled('true');
$dompdf = new Dompdf($options);

//setup the paper size and orientation (optional)
$dompdf->setPaper('A4', 'portrait');

//add custom css
//input type text related customization is needed to handle correctly form inputs and their labels
$customCSS = "<style>
input[type=text]:before { border: 1px solid #FFF; }
label { display: block; padding-bottom: 2px; }
</style>
";

$aPDFcontent = $customCSS . $aPDFcontent;

$dompdf->loadHtml($aPDFcontent, 'UTF-8');
//Render the HTML as PDF
$dompdf->render();

//Handling attachments
$attachments = [];
$pdfAttachments = [];

if(!empty($aPDFattachments)) {
if (isset($aPDFattachments['attachment_content'])) {
$attachments[0] = $aPDFattachments;
} else {
$attachments = $aPDFattachments;
}

$i = 0;
foreach ($attachments as $attachment) {
$tmpfname = tempnam(sys_get_temp_dir(), 'pdf');

$handle = fopen($tmpfname, "w");
fwrite($handle, $attachment['attachment_content'] ?? '');
fclose($handle);

$i++;
$pdfAttachments[] = [
'name' => $attachment['attachment_name'] ?? 'attachment_' . $i . '.xml',
'mime' => 'text/xml',
'description' => $attachment['attachment_description'] ?? '',
'AFRelationship' => 'Alternative',
'path' => $tmpfname
];
}
}

/** @var Cpdf $cpdf */
$cpdf = $dompdf->getCanvas()->get_cpdf();

foreach ($pdfAttachments as $attachment) {
$cpdf->addEmbeddedFile(
$attachment['path'],
$attachment['name'],
$attachment['description']
);
}

//Output the generated PDF as String
return $dompdf->output();
}

Tamás Bulyáki

unread,
Oct 25, 2020, 3:57:32 AM10/25/20
to dompdf
For some reason the workaround image had been trimmed out, so here it is again:


function parse() {
$this->parseTableEntries();

$this->data = array();

foreach ($this->directory as $tag => $table) {
if (empty($this->data[$tag])) {
if (!in_array($tag,array("head", "hhea", "cmap", "hmtx", "maxp", "glyf", "loca", "name", "post"))){
$tag = 'CMAP';
}
$this->readTable($tag);
}
}
}

Reply all
Reply to author
Forward
0 new messages