How to Edit Existing pdf using fpdf Library in PHP

Updated on June 27, 2018 in  [R] Scripts
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
1 on September 2, 2015

By the help of FPDI library, I tried to write some exsiting pdf files but able to wirte only single page of pdf.

Below is my code:

require_once '../includes/fpdf/fpdf.php';
 require_once '../includes/fpdf/fpdi.php';
 $pdf = new FPDI();
 $pageCount = $pdf->setSourceFile("contractFinalTrans.pdf");
 $tplIdx = $pdf->importPage(1);
 $pdf->addPage();
 $pdf->useTemplate($tplIdx, 10, 10, 200);
 //set position in pdf document
 // now write some text above the imported page
 //$pdf->SetFont('Arial');
 $pdf->SetFontSize(10);
 $pdf->SetTextColor(255,0,0);
 $pdf->SetXY(50, 50);
 $pdf->Write(0, "page 1");///print this output
 $pdf->SetAutoPageBreak(true,22);
 $pdf->addPage();
 $tplIdx = $pdf->importPage(2);
 //$pdf->addPage();
 $pdf->useTemplate($tplIdx, 10, 10, 200);
 //set position in pdf document
 // now write some text above the imported page
 //$pdf->SetFont('Arial');
 $pdf->SetFontSize(10);
 $pdf->SetTextColor(255,0,0);
 $pdf->SetXY(100 , 100);
 $pdf->Write(0, "page 2");
 $pdf->Output();

Can anyone suggest me how to Edit Existing multiple pdf using fpdf Library in PHP

I have explored many php developer forum related to this issue but I am unable to get satisfactory solutions. Hope this forum help me out for the same issue.

  • Liked by
Reply
0 on June 27, 2018

I got myself stuck on it as well. It seems to be pretty easy when doing so focused on the very one file, but things become tough when it comes to tens of thousands. Personally, I decided to handle that manually though, using some dead-simple tools like this one https://edit-pdf.pdffiller.com/ More because of there’s no need to write a single line of code, it’s ironic, and JS-based interface is pretty fast to save some time on that hell of a work. It’s also a paid one, but a free trial period is enough

  • Liked by
Reply
Cancel