php how to save an fpdi object as a pdf file

dave picture dave · Aug 21, 2015 · Viewed 8.4k times · Source

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?

Answer

René Höhle picture René Höhle · Aug 21, 2015

You can define an output file in the output function.

$filename="/home/user/public_html/test.pdf";
$pdf->Output($filename,'F');