Reputation: 15489
I'm using fpdi for creating/editing my pdfs, and was wondering how to save the output(essentially "save as" a pdf file) to the local harddrive? Example:
$pdf = new FPDI();
$pdf->setSourceFile("test.pdf");
$page= $pdf->importPage(1);
$pdf->addPage();
$pdf->useTemplate($page);
$pdf->Output(); // So instead of outputting to browser, how to save file as a pdf?
Basically instead of outputting the fpdi object, how do i save it as a pdf file?
Upvotes: 2
Views: 14372
Reputation: 36
Using FPDF:
$pdfData = $pdf->Output('nameOfFile.php','F') //Save as pdf file (Make sure you have permisions)
$pdfData = $pdf->Output('nameOfFile.php','S') //Return the document as string
Upvotes: 2
Reputation: 781
FPDI is a extension for FPDF, so you can get the PDF data as a string:
$pdfData = $pdf->Output('', 'S')
You can then save this to disk in any way you want.
Upvotes: 0
Reputation: 27325
You can define an output file in the output function.
$filename="/home/user/public_html/test.pdf";
$pdf->Output($filename,'F');
Upvotes: 10