Displaying UTF characters in the FPDF

It is very easy to show UTF characters in a FPDF generated PDF file. Just use the following conversion function and it will work. Assume you have initialized the FPDF class to $pdf variable and you want to print the string stored in $name variable:

$pdf->Write(iconv(“UTF-8”, “ISO-8859-1”, $name));

It worked for me.

2 Comments

  1. PriyeshJuly 25, 2018

    i have try this but it is not working so following Error:
    Notice: iconv(): Detected an illegal character in input string in

    Reply
  2. RajendraJuly 25, 2018

    Looks like there are some character in the string which have no matching symbol in the target encoding. You can use advanced options of //TRANSLIT or //IGNORE to ignore these characters. Then it should work.

    For reference you can read the manual for iconv here: – http://php.net/manual/en/function.iconv.php

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to top