Hi I am trying to implement a pdf file feature on codeigniter 4 using Dompdf but am getting an error: Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 262148096 bytes)
I am working on my localhost, have tried to increase the memory limit to a larger size but the page keeps loading and never stops. This is only when I try to embed an image in the code like so:
$dompdf = new \Dompdf\Dompdf();
$image=file_get_contents(ROOTPATH."/public/img/ss_logo_bgwhite.png");
$imagedata=base64_encode($image);
$imgpath = '<img src="data:image/png;base64, '.$imagedata.'">';
$HTML='<body><div>'.$imgpath.'</div></body>';
$document_title = "Quote#$quoteId";
$options = $dompdf->getOptions();
$options->setDefaultFont('Helvetica');
$options->set('dpi','120');
$options->set('isRemoteEnabled', TRUE);
// $options->set('isPhpEnabled ', true);
$options->set('isHtml5ParserEnabled',true);
$options->set('tempDir', ROOTPATH.'/public/uploads/');
$dompdf->setOptions($options);
$dompdf->loadHtml($HTML);
$dompdf->setPaper('A4', 'landscape');
$dompdf->render();
$dompdf->stream($document_title, ["compress" => 1, "Attachment" => false]);
I think it a problem with the Dompdf library has anyone come across this issue?
Similar issue: Codeigniter 4 DOMPDF (2.0.0) PNG Image loading issue . PHP version 8.0.17