2

I am recently working in a system that produces a pdf report through a pdf template. I found FPDI for this purpose. I tried the code below however, it keeps me giving this error...

Parse error: syntax error, unexpected T_USE, expecting T_FUNCTION in C:\wamp\www\stalucia\reports\fpdi\src\Fpdi.php on line 11

my tempate pdf is named as edit.pdf

This is my code accordingly..

<?php
require_once('fpdf/fpdf.php');
require_once('fpdi/src/Fpdi.php');

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

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

$pdf->Output();     

Screenshot

Lovepreet Singh
  • 4,792
  • 1
  • 18
  • 36

0 Answers0