I want to add a png-image to an existing pdf file. Therefore I'm trying to integrate FPDI/FPDF into my project, that is based on the SLIM framework with ELOQUENT.
FPDI/FPDF is added with composer ( composer require setasign/fpdi-fpdf
).
I successfully testet the following code in a single php file ("pdf_test.php") directly opened in the browser:
require_once('../vendor/setasign/fpdf/fpdf.php');
require_once('../vendor/setasign/fpdi/fpdi.php');
$pdf = new FPDI();
$filename = '1005236946.pdf';
$pageCount = $pdf->setSourceFile($filename);
$templateId = $pdf->importPage(1);
$pdf->useTemplate($templateId);
$pdf->Image('9959544245.png',268,184,20, 'PNG');
$pdf->Output('F', '1005236946_PNG.pdf');
But when I use this code in SLIM route ("/php_test") I get a "500 Internal Server Error" at this point:
$pageCount = $pdf->setSourceFile($filename);
I've checked that the $pdf-object is created well.
I searched the web but found nothing so far that could help. Maybe it has to do something with the Apache Server and the .htaccess file... ?
Any help very appreciated :-)