我剛剛安裝CakePdf以生成PDF文件。我想使用Mpdf引擎而不是WkHtmlToPdf。使用CakePdf與Mpdf返回BODY錯誤
我已經在我的FormsController
控制器文件中添加了public $components = array('RequestHandler');
。此外,我已經創建了佈局和查看文件,如app/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]
ahhh ...似乎mPDF有一個錯誤...不是真的CakePdf問題。要解決這個問題,只需在控制器中鍵入'error_reporting(0);'。關閉這一個! –