Invoice PAIN & CSV can be uploaded

This commit is contained in:
2026-02-13 22:37:27 +01:00
parent cd526231ed
commit 4f4dff2edd
29 changed files with 1635 additions and 193 deletions

View File

@@ -0,0 +1,46 @@
<?php
namespace App\Providers;
use InvalidArgumentException;
use RuntimeException;
use setasign\Fpdi\Fpdi;
class PdfMergeProvider {
protected array $files = [];
/**
* Fügt eine PDF-Datei zur Merge-Liste hinzu.
*/
public function add(string $filePath): self
{
$this->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);
}
}