Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mpdf not supporting arabic and chinese fonts

Tags:

php

mpdf

I am using mpdf. When I supplied the arabic and chinese words to the WriteHtml(), the resulting pdf containing square boxes instead of those fonts.

Please suggest!

Sample fonts:

I am testing أنا العالم 我的世界
like image 567
pavan kumar Avatar asked Mar 06 '14 10:03

pavan kumar


3 Answers

On mPDF 6.0, we found this made Cantonese work for us:

$mpdf->autoScriptToLang = true;
$mpdf->autoLangToFont = true;

Seems SetAutoFont is now deprecated.

like image 182
jonnybradley Avatar answered Sep 20 '22 07:09

jonnybradley


Add this to your php code:

$mpdf->autoScriptToLang = true;
$mpdf->autoLangToFont = true;

in css file make sure that you have:

font-family: dejavusanscondensed;
direction: rtl;

and finly make sure that all DejaVuSans*.ttf files are in ttfonts folder

like image 41
HOCiNE BEKKOUCHE Avatar answered Sep 20 '22 07:09

HOCiNE BEKKOUCHE


You need to enable the support of PDF Asian font like this:

$pdf = $this->pdf->load();
$pdf->useAdobeCJK = true;
$pdf->SetAutoFont(AUTOFONT_ALL);
like image 22
user3538235 Avatar answered Sep 22 '22 07:09

user3538235