【发布时间】:2015-04-03 12:46:16
【问题描述】:
我正在使用 MPDF 在 codeigniter 中生成 pdf 文件。
我的控制器功能看起来像
function save_pdf($std_id)
{
$data['section1_report']= $this->common_model->get_details('tbl_section1',array('id'=>$std_id));
$html = $this->load->view('reports/section1',$data,true);
// print_r($html);exit;
$this->load->library('pdf');
$pdf = $this->pdf->load();
$pdf->WriteHTML($html);
$pdf->Output();
}
我的pdf 库是
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class pdf {
function pdf()
{
$CI = & get_instance();
log_message('Debug', 'mPDF class is loaded.');
}
function load($param=NULL)
{
include_once APPPATH.'/mpdf/mpdf.php';
if ($params == NULL)
{
$param = '"en-GB-x","A4","","",10,10,10,10,6,3';
}
return new mPDF($param);
}
}
我想从视图文件section1 生成 pdf 文件。但是当我调用控制器函数save_pdf 时,我得到了如下错误
当我print_r($html);exit; 时,它会显示视图文件中的所有内容。我在mpdf/includes/functions.php 中使用preg_replace_callback 而不是preg_replace,但它仍然显示这样的错误
我研究了mpdf 文档,它在纯 php 中正常工作。但我想在Codeigniter 中生成 pdf 文件。
如何解决mpdf 中的此类错误?如果我可以在Codeigniter 中使用mpdf 生成pdf file,我将不胜感激。谢谢。
【问题讨论】:
-
我刚刚用谷歌搜索了“带有 Codeigniter 的 MPDF”,例如davidsimpson.me/2013/05/19/using-mpdf-with-codeigniter
标签: codeigniter mpdf