xjdata 2015-10-10 04:05:40 8205次浏览 5条评论 7 3 0

如果你使用 https://github.com/kartik-v/yii2-mpdf 那么

$pdf = new Pdf([
    // set to use core fonts only
    'mode' => Pdf::MODE_UTF8,
    // A4 paper format
    'format' => Pdf::FORMAT_A4,
    // portrait orientation
    'orientation' => Pdf::ORIENT_LANDSCAPE,
    // stream to browser inline
    'destination' => Pdf::DEST_BROWSER,
    // your html content input
    'content' => '你好,世界',
    // format content from your own css file if needed or use the
    // enhanced bootstrap css built by Krajee for mPDF formatting
    'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css',
    // any css to be embedded if required
    'cssInline' => '.kv-heading-1{font-size:24px}',
    // set mPDF properties on the fly
    'options' => [
        'title' => '中文',
        'autoLangToFont' => true,    //这几个配置加上可以显示中文
        'autoScriptToLang' => true,  //这几个配置加上可以显示中文
        'autoVietnamese' => true,    //这几个配置加上可以显示中文
        'autoArabic' => true,        //这几个配置加上可以显示中文
    ],
    // call mPDF methods on the fly
    'methods' => [
        'SetHeader' => ['中文'],
        'SetFooter' => ['{PAGENO}'],
    ]
]);

觉得很赞
亿速云
您需要登录后才可以评论。登录 | 立即注册