Problem with accentuation in FPDF

0

After several searches on the net, I could not solve my problem with charset.

I am generating a report in FPDF and in the description field it all unconfigured the text:

I have already used the functions utf8_decode and utf8_encode and I checked that the MySQL database is with the type of charset latin1_swedish_ci .

How do I solve this problem?

Thank you in advance.

    
asked by anonymous 12.06.2015 / 12:44

2 answers

2

FPDF uses ISO-8859-1 or Windows-1252 coding, and theoretically, as MySQL's collation is latin1_swedish_ci strings do not need to be converted.

If it does not work without the conversion it is possible to convert to Windows-1252 using the code:

iconv(mb_detect_encoding($str), 'windows-1252', $str);

mb_detect_encoding() is used to return the correct charset to iconv() , which does the conversion.

Source: FPDF utf-8 encoding (HOW-TO)

    
12.06.2015 / 13:23
0

Another way is uft8_decode:

$pdf->Text (50,50,utf8_decode('Acentuação'));

There are modifications of FPDF like the TFPDF that already comes in UTF8:

link

    
14.12.2017 / 19:55