2013-07-02 29 views
1

我剛剛安裝CakePdf以生成PDF文件。我想使用Mpdf引擎而不是WkHtmlToPdf。使用CakePdf與Mpdf返回BODY錯誤

我已經在我的FormsController控制器文件中添加了public $components = array('RequestHandler');。此外,我已經創建了佈局和查看文件,如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

ahhh ...似乎mPDF有一個錯誤...不是真的CakePdf問題。要解決這個問題,只需在控制器中鍵入'error_reporting(0);'。關閉這一個! –

回答

0

更改1/2調試值 - > 0在app /配置/核心.php

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

感謝@ArunJain,但我現在在開發服務器上。生產完成後,將設置debug = 0。 –

+0

我做的最好的事情是編輯mpdf.php,並將條件if(isset()...放在警告來的相同行中......即使在調試模式下它也適用於我。 –