1

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

我已经添加public $components = array('RequestHandler');了我的FormsController控制器文件。此外,我已经创建了布局和视图文件,例如 soapp/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]
4

1 回答 1

0

在 app/Config/core.php 中将调试值从 1/2 -> 0 更改

Configure::write('debug', 0);
于 2013-07-03T06:13:54.933 回答