使用Yii框架2,我使用kartik\mpdf\Pdf
类将我的HTML页面以PDF格式响应到浏览器。以下是我的配置。
$pdf = new kartik\mpdf\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' => $htmlContent,
// 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} .page-break{ page-break-after:always; } li { list-style:none; }',
// set mPDF properties on the fly
'options' => ['title' => 'My title'],
// call mPDF methods on the fly
'methods' => [
'SetHeader'=>['My_header_ ' . date('d-m-Y')],
'SetFooter'=>['{PAGENO}'],
],
]);
// return the pdf output as per the destination setting
return $pdf->render();
一切都很完美,除非我的HTML页面中有一个变量,它返回一个长字符串,该文本变小。我该如何解决?