Reputation: 71
use ZanySoft\LaravelPDF\PDF;
$mpdf = new PDF();
$mpdf->SetImportUse();
$pagecount = $mpdf->SetSourceFile(storage_path() . '/app/public/applications/test.pdf');
// test.pdf have 2 pages $pagecount have value 2.
for($i=1; $i <= $pagecount ; $i++) {
$tplId = $mpdf->ImportPage($i);
$mpdf->addPage();
$mpdf->UseTemplate($tplId);
// store each page as pdf file
$new_file_name = "new-".$i.".pdf";
$mpdf->Output($new_file_name, \Mpdf\Output\Destination::FILE);
}
I am getting an error Class 'Mpdf\Output\Destination' not found. I have tried below things as second argument of Output();
But, it is not working. Please help to store fetch page store as PDF file direct on directory.
Upvotes: 0
Views: 601
Reputation: 6755
ZanySoft\LaravelPDF\PDF
uses mPDF in version 6.1
which does not have output destination class constants yet.
Use a plain string:
$mpdf->Output($new_file_name, 'F');
Or use composer package mpdf/mpdf
in version >=7
directly.
Upvotes: 1