![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set encoding in PHP FPDI library?
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.
Advertisements