我試圖添加第三方類(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();
你會得到什麼錯誤? –
請看看這個鏈接... http://bakery.cakephp.org/articles/segy/2012/01/19/mpdf_component_for_generating_pdf_files_from_html ...一個演示代碼鏈接也提供在那裏.. –
仔細檢查你的目錄。有'供應商'和'應用程序/供應商'。你在答案中提到的路徑都不符合這些。還是僅僅是一個錯字? –