Project

General

Profile

utf-8 / html character in table utf-8

Added by Marco Steindl over 10 years ago

Hi,
I use the "Fpdf Advanced Table Utf8" (updated today to version 5.0), but have problems with some UTF-8 characters (which comes as html characters like "ä" for the German umlaut "ä")
If I output it as a "Cell" or "MultiCell", it will be displayed correctly as "ä" or "ö" etc., but when using the oTable, there are wrong characters in the PDF (like "ä ö Ã1⁄4 Ä Ö Ãœ ß" instead of "ä ö ü Ä Ö Ü ß").

I tried some en/decodes (mb_convert_encoding, html_entity_decode (or encode)...), but for example if I convert my string with "html_entity_decode($string, ENT_COMPAT | ENT_HTML401, 'ISO-8859-15' )", the German umlauts
will be displayed correctly, but there is a line break on a wrong position, like this:

Output should be the whole row (there is enough space to the right size):
Prüfe Sub-Block

but it is like:
Prüfe Sub-Bloc
k

^

(or at a longer string, the line break is not correctly, so a part of the string will be snipped, before the line breaks)

Do you have any idea, what to do to make the output correctly?

Thanks!


Replies (7)

RE: utf-8 / html character in table utf-8 - Added by Andrei Bintintan over 10 years ago

Hi,

This is either a font file or encoding issue.
Can you upload a very small example(just the example file) which generates this case? I would be able to debug it much faster...

Andrei.

RE: utf-8 / html character in table utf-8 - Added by Marco Steindl over 10 years ago

Hi,

thanks for your fast response!

Attached there is a test source code and the generated pdf...
(in the pdf you can see, that in the table the strings starts on different position)

If possible, I need a generated pdf, which shows the german umlauts like "ü" [= (amp)uuml(semicolon)] and also a "ü" correctly (some data will come from a language file which contains the html-encoded (amp)uuml(;) and from a utf-8 based mysql result)

Thanks!

Marco

test.pdf View test.pdf 6.86 KB generated pdf
test.php test.php 1.69 KB source

RE: utf-8 / html character in table utf-8 - Added by Andrei Bintintan over 10 years ago

Thanks. I can see the problem, but I found some others. I will get back to you.

RE: utf-8 / html character in table utf-8 - Added by Andrei Bintintan over 10 years ago

Issue opened for re visioning #558

RE: utf-8 / html character in table utf-8 - Added by Andrei Bintintan over 10 years ago

Hi Marco,

There was a mistake I did in the example-table-1-overview.php. I have not included the font-files.
For some fonts tFpdf does not deliver proper font metrics if the font-files are not included, this seems to be the case here. Another problem was that the HTML entities were not decoded to UTF8 encoding.
In the source code there is dejavu fontset delivered due to license rights.

What you have to do:

  • please take the latest version of the classes
  • add the fonts to your example(look into examples)
  • let me know about the results.

RE: utf-8 / html character in table utf-8 - Added by Marco Steindl over 10 years ago

Hi Andrei,

thanks - now it works fine :o)

Thanks a lot for fast solving and your quick response every time - you just made my day ;)

Best regards Marco

    (1-7/7)