![]() |
打篮球的骆驼 · 关于KMS批量激活客户端_51CTO博客_o ...· 4 月前 · |
![]() |
侠义非凡的苦瓜 · Mysql中通过关联update将一张表的一 ...· 6 月前 · |
![]() |
俊秀的盒饭 · 将zip压缩的[]byte转换为解压的[]b ...· 11 月前 · |
![]() |
傲视众生的拐杖 · java core ...· 1 年前 · |
![]() |
大力的充值卡 · Mac配置jdk环境并安装IDEA_mac ...· 1 年前 · |
我使用MPDF在代码点火器中生成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
中的此类错误?如果能在
pdf file
中使用
mpdf
生成
Codeigniter
,我将不胜感激。谢谢。
尝试用以下内容替换
functions.php
的第79和80行:
$str = preg_replace_callback('/\&\#([0-9]+)\;/m', function($m) use ($lo){return code2utf($m[1],$lo); }, $str);
$str = preg_replace_callback('/\&\#x([0-9a-fA-F]+)\;/m', function($m) use ($lo){return codeHex2utf($m[1],$lo);}, $str);
我替换了这几行:
$str = preg_replace('/\&\#([0-9]+)\;/me', "code2utf('\\1',{$lo})",$str);
$str = preg_replace('/\&\#x([0-9a-fA-F]+)\;/me', "codeHex2utf('\\1',{$lo})",$str);
用这一行:
$str = preg_replace_callback('/\&\#([0-9]+)\;/m', function($m) use ($lo){return code2utf($m[1],$lo); }, $str);
$str = preg_replace_callback('/\&\#x([0-9a-fA-F]+)\;/m', function($m) use ($lo){return codeHex2utf($m[1],$lo);}, $str);
而且运作正常。
$str = preg_replace('/\&\#([0-9]+)\;/me', "code2utf('\\1',{$lo})",$str);
$str = preg_replace('/\&\#x([0-9a-fA-F]+)\;/me', "codeHex2utf('\\1',{$lo})",$str);
// Remove above and add below code in includes/functions.php
$str = preg_replace_callback('/\&\#([0-9]+)\;/m', function($m) use ($lo){return code2utf($m[1],$lo); }, $str);
$str = preg_replace_callback('/\&\#x([0-9a-fA-F]+)\;/m', function($m) use ($lo){return codeHex2utf($m[1],$lo);}, $str);
// Also comment below line in mpdf.php
$html = preg_replace('/\{DATE\s+(.*?)\}/e',"date('\\1')",$html );