How to set encoding in PHP FPDI library?

PHPServer Side ProgrammingProgramming

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);

The following are three possible encodings that are possible.

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źń');

Note− If the string sent by the user to the PDF is in UTF-8 encoding, it needs to be converted to cp1250.

raja
Published on 27-Dec-2019 08:12:05
Advertisements