mpdf不支持中文字体 [英] mpdf not supporting chinese fonts

查看:872
本文介绍了mpdf不支持中文字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用mpdf.当我尝试将中文单词写入WriteHtml()时,生成的pdf包含方形框而不是那些字体.

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_charset_conversion = false;
$pdf = $this->pdf->load();
$pdf->useAdobeCJK = true;
$pdf->SetAutoFont(AUTOFONT_ALL);
$mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8']); 
$mpdf->SetHeader('|<h2>Booking Invoice</h2>|');
$mpdf->setFooter('{PAGENO}'); 
$mpdf->autoScriptToLang = true;
$mpdf->autoLangToFont = true;    
$mpdf->SetDisplayMode('fullpage');
 ob_start();

 include "test.php";
$html = ob_get_contents();
ob_end_clean();

$mpdf->WriteHTML($html);

我尝试了mpdf 6.0及更高版本,但结果仍然相同

i tried mpdf 6.0 and above version, but still same result

请咨询

谢谢.

推荐答案

我已解决此问题,如果您遇到相同的错误,请检查此问题

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);

这篇关于mpdf不支持中文字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆