2014-03-05 78 views
1

我試圖添加第三方類(mPDF)到我的項目。我在做什麼錯了?我把所有的文件到app/Vendor/mPDF目錄並作出如何將第三方類加載到我的cakephp項目中?

 App::import('Vendor', 'mPDF', array('file' => 'mPDF'.DS.'mpdf.php')); 

     $this->mpdf = new $this->mPDF1(); 
     $html = '<font> TEST</font>'; 

     $this->mpdf->WriteHTML($html); 
     $this->mpdf->Output(); 

編輯: 現在代碼看起來像這樣:

public function grafikRehabilitant(){ 
    $this->autoRender=false; 
    $this->layout='pusty'; 
    App::import('Vendor', 'mPDF', array('file' => 'mPDF'.DS.'mpdf.php')); 

    $mpdf = new mPDF(); 
    $html = '<font> TEST</font>'; 

    $mpdf->WriteHTML($html); 
    $mpdf->Output(); 

} 

這裏是錯誤:

Notice (8): Undefined index: BODY [APP\Vendor\mPDF\classes\cssmgr.php, line 966]

Notice (8): Undefined index: BODY>>ID>> [APP\Vendor\mPDF\classes\cssmgr.php, line 1011]

Notice (8): Undefined offset: -1 [APP\Vendor\mPDF\classes\cssmgr.php, line 1150]

Notice (8): Undefined index: outline-s [APP\Vendor\mPDF\mpdf.php, line 3892]

Notice (8): Undefined property: mPDF::$hasOC [APP\Vendor\mPDF\mpdf.php, line 27505]

Notice (8): Undefined property: mPDF::$hasOC [APP\Vendor\mPDF\mpdf.php, line 27608]

Notice (8): Undefined property: mPDF::$hasOC [APP\Vendor\mPDF\mpdf.php, line 9158]

Warning (2): Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\lib\Cake\Utility\Debugger.php:801) [APP\Vendor\mPDF\mpdf.php, line 7447]

Warning (2): Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\lib\Cake\Utility\Debugger.php:801) [APP\Vendor\mPDF\mpdf.php, line 1736]

mPDF error: Some data has already been output to browser, can't send PDF file

完整的工作代碼

  $this->autoRender=false; 
      $this->layout='pusty'; 
      error_reporting(0); 
      App::import('Vendor', 'mPDF', array('file' => 'mPDF'.DS.'mpdf.php')); 

      $mpdf = new mPDF(); 
      $html = '<font> TEST</font>'; 

      $mpdf->WriteHTML($html); 
      $mpdf->Output(); 
+0

你會得到什麼錯誤? –

+0

請看看這個鏈接... http://bakery.cakephp.org/articles/segy/2012/01/19/mpdf_component_for_generating_pdf_files_from_html ...一個演示代碼鏈接也提供在那裏.. –

+0

仔細檢查你的目錄。有'供應商'和'應用程序/供應商'。你在答案中提到的路徑都不符合這些。還是僅僅是一個錯字? –

回答

2

您收到的最後兩個錯誤是由以前的通知引起的。通過查看NISHANT索蘭奇鏈接的代碼,我看到他們都在導入之前supressing通知,像這樣:

// mPDF class has many notices - suppress them 
error_reporting(0); 

// mPDF import follows 

未經通知,該headers already sent不會發生。

+0

現在這個數字1不存在。我只是改變班級的名字以查看其他錯誤。 – przeqpiciel

+0

@przeqpiciel我更新了我的回答 –

+0

你是fu%$ ng真棒! – przeqpiciel

相關問題