我在使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