Php yii2 pdf生成不工作

Php yii2 pdf生成不工作,php,pdf,yii2,mpdf,Php,Pdf,Yii2,Mpdf,我已使用此链接安装mpdf, 这是行不通的 我的行动是: public function actionReport() { // get your HTML raw content without any layouts or scripts $content = '<html><head></head><body><h1 class="kv-heading-1">hello</h1></body><

我已使用此链接安装mpdf, 这是行不通的

我的行动是:

 public function actionReport() {
 // get your HTML raw content without any layouts or scripts
 $content = '<html><head></head><body><h1 class="kv-heading-1">hello</h1></body></html>';

 // setup kartik\mpdf\Pdf component
 $pdf = new Pdf([
   // set to use core fonts only
   'mode' => Pdf::MODE_CORE,
   // A4 paper format
   'format' => Pdf::FORMAT_A4,
   // portrait orientation
   'orientation' => Pdf::ORIENT_PORTRAIT,
   // stream to browser inline
   'destination' => Pdf::DEST_BROWSER,
   // your html content input
   'content' => $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:18px}',
   // set mPDF properties on the fly
   'options' => ['title' => 'Krajee Report Title'],
   // call mPDF methods on the fly
   'methods' => [
     'SetHeader'=>['Krajee Report Header'],
     'SetFooter'=>['{PAGENO}'],
   ]
 ]);

 // return the pdf output as per the destination setting
 return $pdf->render();
}
public function actionReport(){
//在没有任何布局或脚本的情况下获取HTML原始内容
$content='hello';
//安装kartik\mpdf\Pdf组件
$pdf=新pdf([
//设置为仅使用核心字体
'mode'=>Pdf::mode_CORE,
//A4纸张格式
'format'=>Pdf::format_A4,
//纵向
“方向”=>Pdf::ORIENT_肖像,
//流到浏览器内联
“目的地”=>Pdf::目的地浏览器,
//您的html内容输入
“内容”=>$content,
//如果需要,从您自己的css文件格式化内容或使用
//Krajee为mPDF格式构建的增强引导css
//“cssFile'=>”@vendor/kartik-v/yii2 mpdf/assets/kv mpdf bootstrap.min.css',
//如果需要,将嵌入任何css
'cssInline'=>'.kv-heading-1{font size:18px}',
//动态设置mPDF属性
“选项”=>[“标题”=>“克拉吉报告标题”],
//动态调用mPDF方法
“方法”=>[
“SetHeader”=>[“Krajee报告头”],
'SetFooter'=>['{PAGENO}'],
]
]);
//根据目标设置返回pdf输出
返回$pdf->render();
}
输出:

我应该为pdf做些什么

尝试使用

 // set to use core fonts only
'mode' => Pdf::MODE_BLANK,

我认为您的问题是由于呈现文档时使用的编码。我过去也遇到过一些类似的问题,将模式设置为UTF8似乎总能解决我的问题

'mode' => Pdf::MODE_UTF8

在我的情况下,模式\u BLANK和模式\u UTF8都不起作用