11

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 أنا العالم 我的世界
pavan kumar
  • 391
  • 3
  • 6
  • 13

5 Answers5

31

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

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

Seems SetAutoFont is now deprecated.

Peter O.
  • 32,158
  • 14
  • 82
  • 96
jonnybradley
  • 620
  • 5
  • 6
  • I also found that you need `$mpdf->allow_charset_conversion = false;`. Even with the addition of the above modifications. – Sablefoste Nov 29 '16 at 19:18
17

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

5

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

$pdf = $this->pdf->load();
$pdf->useAdobeCJK = true;
$pdf->SetAutoFont(AUTOFONT_ALL);
user3538235
  • 1,991
  • 6
  • 27
  • 55
1

I guess this is pretty late but I've tried this for Arabic language using version 8.x and it worked for me.

$mpdf = new Mpdf();
$mpdf->autoLangToFont = true;
$mpdf->WriteHTML($html);

I needed to add $mpdf->autoLangToFont = true; because some fonts don't render arabic and that's where it gets messy with squares, etc.

for more information here

Eslam Radi
  • 19
  • 3
-1

Have you looked at the latest release, version 6? It contains a lot of upgrades for foreign languages.

mozgras
  • 3,215
  • 3
  • 21
  • 17
  • Hi I am using mpdf 7.1, I am using CKEdior to get html from the user, but still It is not supporting. I found the some workaround by applying tag with "fontfamily: arial" declaration its working fine. But we can't expect to insert span to the foreign language...! – pavan kumar Mar 08 '14 at 08:45