0% found this document useful (0 votes)
210 views1 page

How To Edit Existing PDF Using FPDF Library in PHP

This document contains code to generate a multi-page PDF document by importing pages from an existing PDF file and adding text to each page. It imports the first two pages of a source PDF file, adds each page to a new document, sets the font and text color, positions the text, and writes a label on each page before outputting the final PDF.

Uploaded by

adri781
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
210 views1 page

How To Edit Existing PDF Using FPDF Library in PHP

This document contains code to generate a multi-page PDF document by importing pages from an existing PDF file and adding text to each page. It imports the first two pages of a source PDF file, adds each page to a new document, sets the font and text color, positions the text, and writes a label on each page before outputting the final PDF.

Uploaded by

adri781
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

view sourceprint?

01 require_once '../includes/fpdf/fpdf.php';
02 require_once '../includes/fpdf/fpdi.php';
03 $pdf = new FPDI();
04 $pageCount = $pdf->setSourceFile("contractFinalTrans.pdf");
05 $tplIdx = $pdf->importPage(1);
06 $pdf->addPage();
07 $pdf->useTemplate($tplIdx, 10, 10, 200);
08 //set position in pdf document
09 // now write some text above the imported page
10 //$pdf->SetFont('Arial');
11 $pdf->SetFontSize(10);
12 $pdf->SetTextColor(255,0,0);
13 $pdf->SetXY(50, 50);
14 $pdf->Write(0, "page 1");///print this output
15 $pdf->SetAutoPageBreak(true,22);
16 $pdf->addPage();
17 $tplIdx = $pdf->importPage(2);
18 //$pdf->addPage();
19 $pdf->useTemplate($tplIdx, 10, 10, 200);
20 //set position in pdf document
21 // now write some text above the imported page
22 //$pdf->SetFont('Arial');
23 $pdf->SetFontSize(10);
24 $pdf->SetTextColor(255,0,0);
25 $pdf->SetXY(100 , 100);
26 $pdf->Write(0, "page 2");
27 $pdf->Output();

You might also like