How to use mPDF for Chinese Language

后端 未结 2 1566
太阳男子
太阳男子 2021-01-13 08:15

I am using mPDF to save form input data to PDF. For English, it is working fine. Anyone can use this code to save HTML Form data to PDF.

Issue: In order to fulfill m

相关标签:
2条回答
  • 2021-01-13 08:47

    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 example – files using chinese font.

    0 讨论(0)
  • 2021-01-13 09:03

    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

    0 讨论(0)
提交回复
热议问题