大家好,当我试图在循环中保存多个PDF文件时,我在Codeigniter中遇到了dompdf的问题。它只保存一个文件,但我需要为每个用户分别保存多个文件到文件夹中。
"我试过了“
public function export_information(){
$this->load->library('pdf');
$export_info_sql = "SELECT * FROM offences_issued";
$export_info_query = $this->db->query($export_info_sql);
$export_info_result = $export_info_query->result();
$query_html = "";
$counter = 1;
foreach ($export_info_result as $offence) {
$directory_path = FCPATH."offences/".$counter.".pdf";
$query_html .= "<table width=100% border=1>";
$query_html .= "<tr><th>Offence ID</th></tr>";
$query_html .= "<tr><td>".$offence->issued_id."</td></tr>";
$query_html .= "</table>";
$this->pdf->loadHtml($query_html);
$this->pdf->setPaper('A4', 'portrait');
$this->pdf->render();
$output = $this->pdf->output();
if (!file_exists($directory_path)) {
file_put_contents($directory_path, $output);
}
$counter++;
}
// echo $query_html;
// exit;
}
显示此错误
An uncaught Exception was encountered
Type: Dompdf\Exception
Message: No block-level parent found. Not good.
Filename: D:\xampp\htdocs\project101\application\libraries\dompdf\src\Positioner\Inline.php
Line Number: 44
Backtrace:
File: D:\xampp\htdocs\project101\application\libraries\dompdf\src\FrameDecorator\AbstractFrameDecorator.php
Line: 873
Function: position
File: D:\xampp\htdocs\project101\application\libraries\dompdf\src\FrameReflower\Inline.php
Line: 51
Function: position
File: D:\xampp\htdocs\project101\application\libraries\dompdf\src\FrameDecorator\AbstractFrameDecorator.php
Line: 894
Function: reflow
File: D:\xampp\project101\project101\application\libraries\dompdf\src\FrameReflower\Page.php
Line: 141
Function: reflow
File: D:\xampp\htdocs\project101\application\libraries\dompdf\src\FrameDecorator\AbstractFrameDecorator.php
Line: 894
Function: reflow
File: D:\xampp\htdocs\project101\application\libraries\dompdf\src\Dompdf.php
Line: 842
Function: reflow
File: D:\xampp\htdocs\project101\application\controllers\Portal.php
Line: 45
Function: render
File: D:\xampp\htdocs\project101\index.php
Line: 315
Function: require_once
1条答案
按热度按时间yizd12fk1#
这解决了问题
https://github.com/dompdf/dompdf/issues/902#issuecomment-431804432