- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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.
- PHP – How to set the character encoding detection order using mb_detect_order()?
- Detect base64 encoding in PHP?
- PHP – How to detect character encoding using mb_detect_encoding()
- Convert ASCII TO UTF-8 Encoding in PHP?
- PHP – Get or set the HTTP output character encoding with mb_http_output()
- PHP – Set the current setting for character encoding conversion using iconv_set_encoding() function
- PHP – Detect HTTP input character encoding with mb_http_input()
- PHP – Convert a string to a requested character encoding using iconv()
- How to include the character encoding in HTML?
- Program to define set data structure without using library set class in Python
- PHP – Get aliases of a known encoding type using mb_encoding_aliases()
- URL Encoding in HTML5
- Run Length Encoding in Python
- How to set a single pixel using imagesetpixel() function in PHP?