In PHP, normally we create PDF using FPDF class by plotting all data against the (x,y) co-ordinates or create the html layout and convert it to a pdf using HTML to pdf. But when we are filling up forms with a number of fields such as an insurance claim form it becomes difficult as we have to start from scratch and plot data field by field. This makes it a huge task.
FPDI class converts a PDF file to an image and includes it in the PDF file we are generating. So what ever data we are plotting on the PDF is actually we are plotting on an image of included pdf. fpdi_tpl.php help us to positioning the image against the co-ordinates and set the width of the image.
// initiate FPDI
$pdf =& new FPDI();
// add a page
// set the sourcefile
// import page 1
$tplIdx = $pdf->importPage(1);
// use the imported page and place it at point 10,10 with a width of 200 mm (This is the image of the included pdf)
$pdf->useTemplate($tplIdx, 10, 10, 200);
// now write some text above the imported page