PHPPdf
PHPPdf copied to clipboard
"ÿþ" (BOM?) in Bookmarks
I don't seem to be able to get bookmarks to work correctly. I see #26 references encoding issues with bookmarks, but I'm not positive this is related.
$facade = PHPPdf\Core\FacadeBuilder::create()->build();
$doc = '<pdf><page><div bookmark="aaa">A</div>
<div bookmark="bbb">B</div></page></pdf>';
$content = $facade->render($doc);
file_put_contents('./out.pdf', $content);
results in the following bookmarks:
ÿþa
ÿþb
And what I believe are the relevant lines in the PDF:
8 0 obj
<</Title (ÿþa
I can fix that behavior by changing the encoding used for rendering with the following patch. But I don't know if it's a good idea or not. I don't know if there is a need to encode in UTF-16.
Ping @psliwa
Doing what I've done in the patch breaks other things like accentuated characters like é or ë. So that's not a good idea !