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