我刚刚安装了 CakePdf 来生成 PDF 文件。我想使用 Mpdf 引擎而不是 WkHtmlToPdf。
我已经添加public $components = array('RequestHandler');
了我的FormsController
控制器文件。此外,我已经创建了布局和视图文件,例如 soapp/View/Layouts/pdf/default.ctp
和app/View/Forms/pdf/view.ctp
.
以下是我创建代码的方式:
<?php
// the rest of the codes
public function view($id=null) {
$kid = $this->FormU5mrn->find('first', array(
'conditions' => array('FormU5mrn.id' => $id),
));
$filename = 'U5MR-' . $kid['FormU5mrn']['ref_no'] . '.pdf';
$this->pdfConfig = array(
'orientation' => 'portrait',
'filename' => $filename
);
$this->set(compact('kid'));
}
我收到以下错误:
Notice (8): Undefined index: BODY [APP/Plugin/CakePdf/Vendor/mpdf/mpdf.php, line 14242]
Notice (8): Undefined index: BODY>>ID>> [APP/Plugin/CakePdf/Vendor/mpdf/mpdf.php, line 14288]
Notice (8): Undefined offset: -1 [APP/Plugin/CakePdf/Vendor/mpdf/mpdf.php, line 14421]
Notice (8): Undefined property: mPDF::$hasOC [APP/Plugin/CakePdf/Vendor/mpdf/mpdf.php, line 27777]
Notice (8): Undefined property: mPDF::$hasOC [APP/Plugin/CakePdf/Vendor/mpdf/mpdf.php, line 27879]
Notice (8): Undefined property: mPDF::$hasOC [APP/Plugin/CakePdf/Vendor/mpdf/mpdf.php, line 8772]