How to use mPDF for Chinese Language

流过昼夜 提交于 2019-12-01 08:25:06

Do not use 'c' as a $mode parameter, that means PDF core fonts only and they do not support chinese characters.

Try '+aCJK' or '-aCJK' instead.

See examplefiles using chinese font.

My Code is as follow [mpdf v7.0 from composer]

<?php
require_once './vendor/autoload.php';
//report errors
error_reporting(E_ALL);
ini_set("display_errors", 1);

$config = [
    'mode' => '+aCJK', 
    // "allowCJKoverflow" => true, 
    "autoScriptToLang" => true,
    // "allow_charset_conversion" => false,
    "autoLangToFont" => true,
];
$mpdf=new \Mpdf\Mpdf($config);

$mpdf->WriteHTML('Hello World 中文');
$mpdf->Output();

This code works fine, you can try it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!