mpdf export chinese character

本文介绍如何在 MPDF 中正确配置以支持中文字符的导出,包括设置 autoScriptToLang 和 autoLangToFont 参数,以及选择合适的字体。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

mpdf export chinese char:
vendor/mpdf/mpdf/config.php, change below two line to true, for v6

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

autoScriptToLang is variable to indicate whether add below inline style to no-ascii char in html source;

<span lang="und-Hans" class="lang_und-Hans"></span>Yii2 Grid<span lang="und-Hans" class="lang_und-
 Hans">导出的</span>

autoLangToFont is a variable to indicate whether to choose font with upper’s inline style’s data;

for chinese:
useAdobeCJK is true: font is gb/big5. it will use adobe’s cjk font
useAdobeCJK is false: font will be Sun-ExtA.ttf

usingCoreFont: if there exist font-family style in html content, mpdf will try to resolve it to it’s inner font, if this process is success, the set this variable to true;

v5 maybe need change:

$this->useAdobeCJK = true;

mpdf’s font issue, can only set font to mpdf’s font, if you want to user system font, you should change it’s code

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值