Below is the same code to set encoding for FPDI library−
Add new fonts that have the correct alphabets.
$pdf->AddFont('DejaVu','','DejaVuSansCondensed.php'); $pdf->SetFont('DejaVu', '', 10, '', false);
以下是可能的三种可能的编码。
cp1250 (Central Europe) cp1251 (Cyrillic) cp1252 (Western Europe) cp1253 (Greek) cp1254 (Turkish) cp1255 (Hebrew) cp1257 (Baltic) cp1258 (Vietnamese) cp874 (Thai) or ISO-8859-1 (Western Europe) ISO-8859-2 (Central Europe) ISO-8859-4 (Baltic) ISO-8859-5 (Cyrillic) ISO-8859-7 (Greek) ISO-8859-9 (Turkish) ISO-8859-11 (Thai) ISO-8859-15 (Western Europe) ISO-8859-16 (Central Europe) Or KOI8-R (Russian) KOI8-U (Ukrainian)
Let us see an example to convert the UTF-8 to cp1250.
$str = iconv('UTF-8', 'cp1250', 'zazółcić gęślą jaźń');
注意− 如果用户发送给PDF的字符串是UTF-8编码,需要将其转换为cp1250。