feat: convert uploaded contracts and invoices to pdf

This commit is contained in:
Björn Fromme
2025-03-04 14:13:09 +01:00
parent ab6d350045
commit 917640183f
9 changed files with 164 additions and 8 deletions
+15
View File
@@ -5,6 +5,7 @@ namespace App\Service\Upload;
use App\Entity\Upload;
use App\Model\UploadDto;
use App\Model\UploadSessionDto;
use App\Service\Pdf\Sanitizer;
use Oneup\UploaderBundle\Uploader\Orphanage\OrphanageManager;
use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Filesystem\Filesystem;
@@ -17,6 +18,7 @@ class UploadHandler
public function __construct(
private readonly RequestStack $requestStack,
private readonly OrphanageManager $orphanageManager,
private readonly Sanitizer $sanitizer,
private readonly string $projectDir
) {
}
@@ -131,4 +133,17 @@ class UploadHandler
{
return sprintf('%s/uploads/temp/%s', $this->projectDir, $uploadSessionId);
}
public function ensurePdf(Upload $upload): void
{
try {
$filepath = $this->getUploadFilepath($upload);
$sanitizedFilepath = $this->sanitizer->sanitizeFile($filepath);
if ($filepath !== $sanitizedFilepath) {
$upload->setFilename(basename($sanitizedFilepath));
}
} catch (\InvalidArgumentException $e) {
}
}
}