-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
I've been using this package for over a year now and suddenly started getting memory exhaustion errors
PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in <[...]>/tcpdi_parser.php on line 882
Here's my code
public function downloadFiles($files, $name = 'name.pdf'){
$pdf = new \TCPDI();
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
$filesArr = [];
$pdf->SetTitle($name);
foreach($files as $f){
$filePath = $f->getFirstMedia('pdf')->getFullUrl();
$width = $f->sheetsize->width;
$height = $f->sheetsize->height;
$port_land = ($width > $height) ? "landscape" : "portrait";
$pdf->AddPage($port_land, array($width, $height));
$pageCount = $pdf->setSourceFile($filePath);
for($i = 1; $i <= $pageCount; $i+=1)
{
$tplId = $pdf->importPage($i);
$pdf->useTemplate($tplId, 0, 0, $width);
if($pageCount > $i){
$pdf->AddPage();
}
}
}
$name = str_replace('.pdf', '', $name).'.pdf';
$pdf->Output($name, "I");
}
I'm attaching one of the pdfs that causes this error, I'm really lost at where should I even begin to look for the problem.
problems.pdf
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels