Open aledeg opened 8 years ago
It looks like this PR breaks bookmarks feature at all (at least on my machines - I've tested this on php 5.3 and 5.5). Are you sure this is the solution? I am not able to reproduce the problem from #102
I was able to reproduce it on my machine. I am running PHP 7. Here is the code of my test to reproduce #102
<?php
error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
set_time_limit(0);
require_once __DIR__.'/../vendor/autoload.php';
$facade = PHPPdf\Core\FacadeBuilder::create()->build();
$doc = <<<DOC
<pdf>
<dynamic-page>
<div bookmark="Hêtre">Hêtre</div>
<div bookmark="Où">Où</div>
<div bookmark="Trouvère">Trouvère</div>
<div bookmark="Étendu">Étendu</div>
</dynamic-page>
</pdf>
DOC;
$content = $facade->render($doc);
header('Content-Type: application/pdf');
echo $content;
And to answer your question, I am really not sure about this being a solution. But it looks like the endianness of the string is the root of the problem.
I tried again on PHP 5.5. I can reproduce with the code above and I can fix it with the PR.
According to that message on stackoverflow (http://stackoverflow.com/questions/8923866/convert-utf8-to-utf16-using-iconv#8924403), choosing which endianness we want to use remove the BOM from the string. The BOM was generated in the bookmarks text during the generation. When forcing the endianness, the BOM is no longer rendered.
See #102