Created
December 6, 2022 02:49
-
-
Save rmcdaniel/a8cf05d95a9d263e9a2ba58535d8d860 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Workflows\BuildPDF; | |
use setasign\Fpdi\Fpdi; | |
use Workflow\Activity; | |
class MergePDFActivity extends Activity | |
{ | |
public function execute($pages) | |
{ | |
$fileName = uniqid() . '.pdf'; | |
$pdf = new Fpdi(); | |
foreach ($pages as $page) { | |
$pdf->AddPage(); | |
$pdf->setSourceFile(storage_path($page)); | |
$pdf->useTemplate($pdf->importPage(1)); | |
} | |
$pdf->Output('F', storage_path($fileName)); | |
foreach ($pages as $page) { | |
unlink(storage_path($page)); | |
} | |
return $fileName; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment