使用CakePdf和Mpdf返回BODY错误

时间:2013-07-02 07:40:10

标签: cakephp mpdf

我刚刚安装了CakePdf来生成PDF文件。我想使用Mpdf引擎而不是WkHtmlToPdf。

我已在public $components = array('RequestHandler');控制器文件中添加FormsController。此外,我已经创建了布局和视图文件,如app/View/Layouts/pdf/default.ctpapp/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]

1 个答案:

答案 0 :(得分:0)

将调试值从1/2更改为&gt; app / Config / core.php中的0

Configure::write('debug', 0);