{"action":"opened","issue":{"url":"https://api.github.com/repos/dompdf/dompdf/issues/1221","repository_url":"https://api.github.com/repos/dompdf/dompdf","labels_url":"https://api.github.com/repos/dompdf/dompdf/issues/1221/labels{/name}","comments_url":"https://api.github.com/repos/dompdf/dompdf/issues/1221/comments","events_url":"https://api.github.com/repos/dompdf/dompdf/issues/1221/events","html_url":"https://github.com/dompdf/dompdf/issues/1221","id":162644729,"number":1221,"title":"UTF-8 text in inline PHP gets transcoded to HTML entities","user":{"login":"rovexo","id":20183572,"avatar_url":"https://avatars.githubusercontent.com/u/20183572?v=3","gravatar_id":"","url":"https://api.github.com/users/rovexo","html_url":"https://github.com/rovexo","followers_url":"https://api.github.com/users/rovexo/followers","following_url":"https://api.github.com/users/rovexo/following{/other_user}","gists_url":"https://api.github.com/users/rovexo/gists{/gist_id}","starred_url":"https://api.github.com/users/rovexo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rovexo/subscriptions","organizations_url":"https://api.github.com/users/rovexo/orgs","repos_url":"https://api.github.com/users/rovexo/repos","events_url":"https://api.github.com/users/rovexo/events{/privacy}","received_events_url":"https://api.github.com/users/rovexo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-06-28T09:45:06Z","updated_at":"2016-06-28T09:45:06Z","closed_at":null,"body":"Hey, it seems like currently all HTML passed to loadHtml gets converted to HTML-entities (according to code comments it's a workaround for an encoding bug in DOMDocument). Problem is that **inline PHP blocks also get converted** (like $pdf->text()). So function parameter strings get transcoded and it results in having actual HTML entity text in the PDF output.\r\n\r\n**Inline PHP in the HTML page:**\r\n\r\n```\r\n<script type=\"text/php\">\r\n$pdf->text(10, 10, 'UTF-8 characters like ß.')\r\n</script>\r\n```\r\n\r\n**Result in the PDF:**\r\n\r\nUTF-8 characters like \\&szlig;.\r\n\r\n**Reproducing:**\r\n\r\n- PHP Version doesn't matter I think\r\n- Release 0.7.0 (or also what's on master and develop at the time of writing)\r\n- Have the option isHtml5ParserEnabled at false\r\n\r\n**Regards:**\r\nDompdf::loadHtml Line 516 (in the current 0.7.0 release).\r\n\r\n**Possible solution:**\r\nSomehow don't encode the inline PHP blocks, only the HTML (maybe splitting, encoding the HTML parts and concatenate afterwards).\r\n\r\nOr have the text method (and similar ones) decode HTML entities.\r\n\r\nBy the way, I'm running PHP 5.4.45 and experimented with Dompdf::loadHtml(): I tried passing the non-encoded HTML string to DOMDocument::loadHTML. All characters came out fine in the PDF. Maybe the mentioned issue is done in later PHP version and a PHP version switch comes in handy (unless people start doing workarounds for the workaround)."}}
{"actor":{"display_login":"rovexo"}}