This is an archived forum post. The information may be outdated. Contact us if you have any questions.

Error with special characters in header and footer

javierisaai wrote on 2011-07-20:

I am using the $pdf->setHeaderHtml() and $pdf->setFooterHtml() PHP functions of the API to set HTML headers and footers for the PDF files I'm trying to build. However, I need to have special accented characters taken into consideration, but when I use them the PDF file generated contains strange symbols in place of the accented characters.

I am using plain special characters typed in directly for the header, but for the footer I am using an HTML table to show information in a specific layout, such information also contains special characters which fail to show correctly. I also use special accented characters in the body of the PDF document, which renders dynamically according to the account profile and processed information, but everything renders beautifully there and without a problem in terms of special characters.

Please see this sample PDF file to see what the error actually looks like on the header and footer.

Thanks for your support!

NOTE: I was unable to post this support request message because I was typing some of the special characters here in the message for you to look at them. I received multiple errors from the forum, where the QUERY showed up as it failed to execute... once I removed the accented characters from the message body then I was able to post this message.
support wrote on 2011-07-20:
Hi Javier, please send your header/footer html code to and we will look into it.
javierisaai wrote on 2011-07-20:

I came up with a temporary fix. I used the htmlentities("accented-chars-here"); PHP function so the special characters would be turned to their proper HTML equivalent tags, such as á É etc.

You should still consider fixing direct input errors though. Thanks in advance.
support wrote on 2011-07-21:

to get the characters displayed correctly, use utf8_encode():

The setHeaderHtml() and setFooterHtml() methods:

  • expect UTF-8 encoded html; setDefaultTextEncoding() is ignored
  • discard the <head> element if present so any possible encoding specification is lost.
javierisaai wrote on 2011-07-21:
I understand the problem now, and everything works as expected.

Thanks a lot for your response and support.