yii2 pdf 生成不工作
yii2 pdf generation not working
我已经使用这个 link pdf yii2 installer 安装了 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();
}
输出:
我应该为 pdf 做什么?
尝试使用
// set to use core fonts only
'mode' => Pdf::MODE_BLANK,
我认为您的问题是由于呈现文档时使用的编码引起的。我过去遇到过几个类似的问题,将模式设置为 UTF8 似乎总能解决我的问题。
'mode' => Pdf::MODE_UTF8
我已经使用这个 link pdf yii2 installer 安装了 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();
}
输出:
我应该为 pdf 做什么?
尝试使用
// set to use core fonts only
'mode' => Pdf::MODE_BLANK,
我认为您的问题是由于呈现文档时使用的编码引起的。我过去遇到过几个类似的问题,将模式设置为 UTF8 似乎总能解决我的问题。
'mode' => Pdf::MODE_UTF8