FPDF utf-8 encoding (HOW-TO)

yorgos picture yorgos · Jun 13, 2011 · Viewed 191.7k times · Source

Does anybody know how to set the encoding in FPDF package to utf-8? Or at least to ISO-8859-7 (Greek) that support greek characters?

Basically I want to create a pdf file containing greek characters.

Any suggestions would help. George

Answer

Michal picture Michal · Jan 30, 2012

Don't use UTF-8 encoding. Standard FPDF fonts use ISO-8859-1 or Windows-1252. It is possible to perform a conversion to ISO-8859-1 with utf8_decode(): $str = utf8_decode($str); But some characters such as Euro won't be translated correctly. If the iconv extension is available, the right way to do it is the following: $str = iconv('UTF-8', 'windows-1252', $str);