Skip to content Skip to sidebar Skip to footer

Mpdf Not Supporting Chinese Fonts

I am using mpdf. When I try to write chinese words to the WriteHtml(), the resulting pdf containing square boxes instead of those fonts. require 'mpdf/mpdf.php'; $mpdf->allow_ch

Solution 1:

Try to:

$mpdf->allow_charset_conversion = true;
$mpdf->charset_in='UTF-8';

Solution 2:

I fix it, please check this if u have same error

header('Content-Type: text/html; charset=UTF-8');
    include("mpdf/mpdf.php");

            $mpdf=new \mPDF('+aCJK','A4','','',15,10,16,10,10,10);
            $mpdf->SetHeader('|Booking Invoice|');
    $mpdf->setFooter('{PAGENO}'); 
            ob_start();
            include('cis.php');

          $html = ob_get_contents();
            ?><?php$html = ob_get_clean();


            $html = iconv('UTF-8', 'UTF-8//IGNORE', $html);
            $html = iconv('UTF-8', 'UTF-8//TRANSLIT', $html);



            $mpdf->SetAutoFont();
            $mpdf->autoScriptToLang = true;
            $mpdf->autoLangToFont   = true;



            $mpdf->WriteHTML($html);

Solution 3:

Use mode on object creation

$mpdf = new Mpdf(['mode' => 'UTF-8']);

and write your utf-8 content to it

Post a Comment for "Mpdf Not Supporting Chinese Fonts"