0

I'm working on a project with OctoberCMS, using DynamicPDF plugin (based on DoomPdf) and can't figure out what is happening.

I'm passing variable $name to the PDF layout, were it would be rendered as {{ name|raw }}.

$name is encoded in UTF-8 in the controller and if I just use {{ name }} in the template characters are dispalyed correctly, but when I use the |raw filer "ő" and "ű" gets converted to "?".

Solutions suggesting to use convert_encoding('UTF-8', 'ISO-8859-1') doesn't work, I already tried lot's of options...

UPDATE: I think that the problem is not with the twig filter, but somewhere in DoomPDF or in Dynamic PDF plugin, because when I preview the template in HTML everything is ok, but when I do the PDF review the problem is there.

zsss
  • 1
  • 4
  • if you are using without `raw` and if it's working then is there any reason to use `raw` .. maybe HTML ? – Hardik Satasiya Oct 19 '21 at 10:36
  • yes, I have HTML in it, I need the `|raw` filter, otherwise I need to rewrite the whole thing – zsss Oct 19 '21 at 10:39
  • It's possible that what's happening is the opposite: _without_ the raw filter, the default escaping is transforming the variable to HTML entities. See if you can save the actual HTML output of the two versions, and compare them, preferably in something like a hex editor to be sure you can see what encoding is actually being used. – IMSoP Oct 19 '21 at 10:43
  • This is what I get without the raw filter: "

    őúéáűíóü

    ". This is what I get with the raw filter: "?úéá?íóü". The output is a PDF file, I don't know how to check the HTML output before it get's converted to PDF.
    – zsss Oct 19 '21 at 10:49
  • If I just do `{{ 'őúéáűíóü'|raw }}` in the layout file, it's also ok. Maybe filter doesn't have any effect here? – zsss Oct 19 '21 at 10:59
  • But if I do ` {% set html = '

    őúéáűíóü

    ' %} {{ html|raw }}` it's working again.
    – zsss Oct 19 '21 at 11:01
  • [can't reproduce](https://twigfiddle.com/ced0zv). Make sure every file (PHP/twig template) is saved as UTF-8 and that you use UTF-8 with you database connection – DarkBee Oct 19 '21 at 11:08
  • Thanks, I think that the problem is not with the twig filter, but somewhere in DoomPDF or Dynamic PDF plugin, because when I preview the template in HTML everything is ok, but when I do the PDF review the problem is there. I'm sorry, my assumption was wrong. – zsss Oct 19 '21 at 11:56

0 Answers0