PHP 7 FPDI Edit Existing PDF Document & Add Text Inside It

PHP 7 FPDI Library Example to Edit or Modify Existing PDF Document and Add Text inside it in Browser


use setasign\Fpdi\Fpdi;


// initiate FPDI
$pdf = new Fpdi();
// add a page
// set the source file
// import page 1
$tplIdx = $pdf->importPage(1);
// use the imported page and place it at position 10,10 with a width of 100 mm
$pdf->useTemplate($tplIdx, 10, 10, 100);

// now write some text above the imported page
$pdf->SetTextColor(255, 0, 0);
$pdf->SetXY(30, 30);
$pdf->Write(0, 'This is just a simple text');

$pdf->Output('I', 'generated.pdf');

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.