dompdf codeigniter,我试图渲染两个htmls我得到渲染错误

时间:2013-07-03 08:37:06

标签: php codeigniter dompdf

dompdf codeigniter,我正在尝试渲染两个html我在渲染时出错

这里是我运行第二次渲染时发生的错误

[Wed Jul 03 09:18:10 2013] [error] [client 127.0.0.1] PHP Fatal error:  Uncaught exception 'DOMPDF_Exception' with message 'No block-level parent found.  Not good.' in /var/www/onplans/application/libraries/dompdf/include/inline_positioner.cls.php:38\nStack trace:\n#0 /var/www/onplans/application/libraries/dompdf/include/frame_decorator.cls.php(546): Inline_Positioner->position()\n#1 /var/www/onplans/application/libraries/dompdf/include/inline_frame_reflower.cls.php(37): Frame_Decorator->position()\n#2 /var/www/onplans/application/libraries/dompdf/include/frame_decorator.cls.php(556): Inline_Frame_Reflower->reflow(NULL)\n#3 /var/www/onplans/application/libraries/dompdf/include/page_frame_reflower.cls.php(138): Frame_Decorator->reflow()\n#4 /var/www/onplans/application/libraries/dompdf/include/frame_decorator.cls.php(556): Page_Frame_Reflower->reflow(NULL)\n#5 /var/www/onplans/application/libraries/dompdf/include/dompdf.cls.php(817): Frame_Decorator->reflow()\n#6 /var/www/onplans/application/controllers/timeline.php(957): DOMPDF->render()\n#7 [internal function]: Timeline->generate_report_ in /var/www/onplans/application/libraries/dompdf/include/inline_positioner.cls.php on line 38, referer:


if ( $reportCouvs[0] == 1 ) { 
    //  $this->pdf->load_html( 'reports/report_comb_1', $Ddata );
    $this->pdf->load_view( 'reports/report_comb_1', $Ddata );
    $this->pdf->render();
    $pdfoutput = $this->pdf->output();
    $filename = "$report_dir/"."cover3.pdf";
    $fp = fopen( $filename, "a" );
    fwrite( $fp, $pdfoutput );
    fclose( $fp );
    $this->pdf->load_view( 'reports/report_comb_2', $Ddata );
    $this->pdf->render();
    $pdfoutputu = $this->pdf->output();
    $filenameu = "$report_dir/"."imagleft3.pdf";
    $fp = fopen( $filenameu, "a" );
    fwrite( $fp, $pdfoutputu);
    fclose( $fp );

} else if( $reportCouvs[0] == 2 ) {
    $this->pdf->load_view('reports/report_comb_2', $Ddata ); 
}

在第二次渲染应用程序崩溃

是否可以使用dompdf

呈现两个文件

1 个答案:

答案 0 :(得分:1)

我也反对这个问题。 出于某些原因可能会发生此错误。您可以检查三个选项:

  • 重新安装DOMPDF库
  • 确保为PHP安装/配置/启用了mbstring
  • 确保在循环时重新初始化或创建新的DOMPDF实例。

听起来你已经成功输出了一个PDF,这表明前两个选项可能不是问题。我们无法看到与此问题相关的完整代码,但似乎很可能是第三种选择。

如果是第三个,那么你应该确保创建pdfs的循环以行开头:

$this->pdf = new DOMPDF();