From 287ba39dc09493bb367d35610d8071174e7fbbc5 Mon Sep 17 00:00:00 2001 From: Philipp Lang Date: Mon, 11 Dec 2023 16:26:34 +0100 Subject: [PATCH] Fixed: delete merged data --- src/BaseCompiler.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/BaseCompiler.php b/src/BaseCompiler.php index 4151b46..5fe814c 100644 --- a/src/BaseCompiler.php +++ b/src/BaseCompiler.php @@ -53,10 +53,11 @@ abstract class BaseCompiler implements Responsable */ public function merge(array $documents): self { - $outfile = '/tmp/' . Str::uuid()->toString() . '.pdf'; + $outfile = new File('/tmp/' . Str::uuid()->toString() . '/' . Str::uuid()->toString() . '.pdf', false); + mkdir($outfile->getPath()); $paths = array_map(fn ($document) => static::compile($document)->getPath(), $documents); $command = collect([ - 'pdfjam --nup 1x1 --outfile ' . $outfile, + 'pdfjam --nup 1x1 --outfile ' . $outfile->getPathname(), ...array_map(fn ($path) => escapeshellarg($path), $paths), ])->implode(' '); @@ -71,7 +72,7 @@ abstract class BaseCompiler implements Responsable throw (new CompilerException('Compilation failed.'))->setOutput($output); } - return static::fromFile($outfile); + return static::fromFile($outfile->getPathname()); } public function storeAs(string $directory, string $name, string $disk): string