files[] = $filePath; return $this; } /** * Führt alle hinzugefügten PDFs zusammen und speichert sie. */ public function merge(string $outputPath): void { if (empty($this->files)) { throw new RuntimeException("No PDF files added for merging."); } $pdf = new FPDI(); foreach ($this->files as $file) { $pageCount = $pdf->setSourceFile($file); for ($page = 1; $page <= $pageCount; $page++) { $tpl = $pdf->importPage($page); $size = $pdf->getTemplateSize($tpl); $pdf->AddPage($size['orientation'], [$size['width'], $size['height']]); $pdf->useTemplate($tpl); } } $pdf->Output('F', $outputPath); } }