I'm trying to merge multiple PDF files using the tool Setasign/FPDI along with their parser FPDI PDF-Parser.
Some PDF files can have drawings like signatures before they are merged. The problem is that after the merging, those drawings are gone.
I'm looking for a solution to ensure that all PDF content is transferred to the final merged output file.
Any help is greatly appreciated.
private function mergeFiles()
{
$fpdi = new Fpdi();
foreach ($files as $file) {
$this->mergePDFFile($fpdi, $file->getFilePath());
}
$fpdi->Output($outputFilePath, 'F');
}
private function mergePDFFile(Fpdi $pdf, $filePath)
{
$pageCount = $pdf->setSourceFile($filePath);
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
$templateId = $pdf->importPage($pageNo);
$size = $pdf->getTemplateSize($templateId);
$pdf->AddPage($size['orientation']);
$pdf->useTemplate($templateId, null, null, null, null, true);
}
}
The original files before merging
The merged files with the unexptected result

