我在使Codeigniter mPDF庫正常工作時遇到了一些麻煩。下面是「應用程序/庫」類:Codeigniter mPDF庫無法加載
class mpdf {
function mpdf() {
$CI = & get_instance();
log_message('Debug', 'mPDF class is loaded.');
}
function load($param = NULL) {
include_once APPPATH . 'third_party/m_pdf/mpdf.php';
if ($params == NULL) {
$param = '"en-GB-x","A4","","",10,10,10,10,6,3';
}
return new mPDF($param);
}
}
,而我的職責是應該打印出來的PDF格式是如下:
//pdf
public function outputPDF() {
//this data will be passed on to the view
$data['the_content'] = 'mPDF and CodeIgniter are cool!';
//load the view, pass the variable and do not show it but "save" the output into $html variable
$html = $this->load->view('pdf_output', $data, true);
//this the the PDF filename that user will get to download
$pdfFilePath = "the_pdf_output.pdf";
//load mPDF library
$this->load->library('mpdf');
//actually, you can pass mPDF parameter on this load() function
$pdf = $this->mpdf->load();
//generate the PDF!
$pdf->WriteHTML($html);
//offer it to user via browser download! (The PDF won't be saved on your server HDD)
$pdf->Output($pdfFilePath, "D");
}
下面是錯誤:
Fatal error: require_once(): Failed opening required 'X:/xampp/htdocs/.../application/third_party/m_pdf/config_cp.php' (include_path='.;X:\xampp\php\PEAR') in X:\xampp\htdocs...\application\third_party\m_pdf\mpdf.php on line 39
Kindly assist
而不是包括嘗試這個 require_once APPPATH。 「THIRD_PARTY/m_pdf/mpdf.php」; $ mpdf = new mPDF('c','A4'); –
嗨,require_once仍然會拋出相同的錯誤 – Kabs