PHPPdf icon indicating copy to clipboard operation
PHPPdf copied to clipboard

"ÿþ" (BOM?) in Bookmarks

Open jakejohns opened this issue 9 years ago • 2 comments

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

jakejohns avatar Nov 05 '15 06:11 jakejohns

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

encoding.txt

aledeg avatar Mar 06 '16 14:03 aledeg

Doing what I've done in the patch breaks other things like accentuated characters like é or ë. So that's not a good idea !

aledeg avatar Mar 06 '16 14:03 aledeg