Hello everyone I am facing a problem with dompdf in Codeigniter when I am trying to save multiple pdf files in a loop. It saves only one file but I need multiple files to save in the folder separately for each user.
I tried this
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;
}
It shows this error
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
This fixed the problem
https://github.com/dompdf/dompdf/issues/902#issuecomment-431804432
html, body { display: block; }