Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Choose endianness for conversion #107

Open
wants to merge 1 commit into
base: 1.2.x
Choose a base branch
from
Open

Choose endianness for conversion #107

wants to merge 1 commit into from

Conversation

aledeg
Copy link
Contributor

@aledeg aledeg commented Mar 6, 2016

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

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
@psliwa
Copy link
Owner

psliwa commented Mar 6, 2016

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

@aledeg
Copy link
Contributor Author

aledeg commented Mar 6, 2016

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.

@aledeg
Copy link
Contributor Author

aledeg commented Mar 7, 2016

I tried again on PHP 5.5. I can reproduce with the code above and I can fix it with the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants