php - yii2 pdf 生成不工作

标签 php pdf yii2 mpdf

我已经使用此链接安装了 mpdf pdf yii2 installer , 这是行不通的。

我的行动是:

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

输出:

output

我应该为 pdf 做什么?

最佳答案

尝试使用

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

关于php - yii2 pdf 生成不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34577469/

相关文章:

yii2 - 如何扩展 Yii2-user dektrium 配置文件模型以能够添加更多字段

php - 如何更改 Yii2 中的目录等 url 参数?

javascript - jquery模态对话框通过id获取输入类型文本的值

PHPmailer 和 pdf 附件

angular - 以 Angular 创建多页PDF

java - PDF 生成不在 IE 中显示

yii2 - yii2 中没有显示错误信息

php - 我无法访问 Laravel routes/api.php 文件的任何路由

php - mysql偏移真实行为

phpMyAdmin 没有登录屏幕