安装
php composer.phar require kartik-v/yii2-mpdf "*"
或者把 "kartik-v/yii2-mpdf": "*" 加到composer.json文件的require段 执行 composer update
$pdf = new Pdf([ 'mode' => Pdf::MODE_UTF8, 'format' => Pdf::FORMAT_A4, 'orientation' => Pdf::ORIENT_LANDSCAPE, 'destination' => Pdf::DEST_BROWSER, //值为Pdf::DEST_FILE时生成文件 'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css',
//设置中文 'options' => [ 'title' => '中文', 'autoLangToFont' => true, 'autoScriptToLang' => true, 'autoVietnamese' => true, 'autoArabic' => true, ], ]); $pdf->content=$contents; $pdf->render();