Search code examples
phpfpdffpdi

FPDI FPDF add page to PDF


I have a PDF file, and I want to add a new second page with about 3 lines of text generated by PHP. I figure FPDI to import the PDF file and FPDF to add the 3 lines of text to a second page. Can't find a tutorial anywhere, not sure how to go about this.

This is FPDI ==> https://www.setasign.com/products/fpdi/about/

  • I want to generate a second page with PHP to add to the already created and uploaded PDF. This is why I put FPDF.

Still being put on hold because of being "too broad" Jeff. What does it take to fully describe what I'm saying here?


Solution

  • You can see manual here. The following sample code shows how to use FPDI.

      $pdf = new FPDI();
    
     $pageCount = $pdf->setSourceFile("Fantastic-Speaker.pdf");
     $tplIdx = $pdf->importPage(1, '/MediaBox');
    
     $pdf->addPage();
     $pdf->useTemplate($tplIdx, 10, 10, 90);
    
     $pdf->Output();