当我尝试一次创建两个pdf时,它会抛出错误......
致命错误:未捕获的异常'DOMPDF_Exception',消息为“否” 找到块级父级。不好。'在 C:\瓦帕\ WWW \ si2i \应用\库\ DOMPDF \包括\ inline_positioner.cls.php 第38行(!)DOMPDF_Exception:找不到块级父级。不 好。在 C:\瓦帕\ WWW \ si2i \应用\库\ DOMPDF \包括\ inline_positioner.cls.php 第38行
这是代码:
$this->load->library('pdf');
$this->pdf->set_base_path($data['path']);
$this->pdf->load_view('adm/invoice/si2i',$data);
$this->pdf->render();
$output = $this->pdf->output();
file_put_contents("uploads/invoice/invoice_".$invoice_file_name.".pdf", $output);
$this->load->library('pdf');
$this->pdf->set_base_path($data['path']);
$this->pdf->load_view('adm/invoice/si2i',$data);
$this->pdf->render();
$output = $this->pdf->output();
file_put_contents("uploads/invoice/invoice_".$invoice_file_name.".pdf", $output);
请帮帮我..
提前致谢...
答案 0 :(得分:5)
我刚遇到同样的问题。解决方案是codeigniter pdf库$ this-> load-> library(' pdf');创建一个每次调用的DOMPDF实例,但是该类在自身之后没有正确清理,因此如果需要生成多个pdf,则会崩溃。
解决方案是根据需要手动实例化DOMPDF类。不要使用codeigniter pdf包装器。
//require at the top of our script
require_once(APPPATH .'libraries/dompdf/dompdf_config.inc.php');
//get the html first (base dompdf cant do the combined load/render)
$view = $this->load->view("viewname", $viewData, true);
//create a new dompdf instance (this is the crucial step)
$this->pdf = new DOMPDF();
//render and output our pdf
$this->pdf->load_html($view);
$this->pdf->render();
$pdf = $this->pdf->output(array("compress" => 0));
file_put_contents("some/file/path.pdf", $pdf );