I receive the following error when using useImportedPage()
for generating labels…
ErrorException [ Fatal Error ]: Call to undefined method FPDI::useImportedPage().
But when I comment out $pdf->useImportedPage($tplIdx, 10, 10, 100);
and un-comment line $pdf->useTemplate($tplidx);
it works fine.
The PDF I import is version 1.4.
Any suggestions as to why useImportedPage()
doesn’t work?
$this->auto_render = false; $this->template = NULL; $offset = 0; require_once('assets/vendors/fpdf/fpdf.php'); require_once('assets/vendors/fpdi/fpdi.php'); $pdf = new Fpdi(); $pdf->addPage(); $pdf->setSourceFile('TEST.pdf'); $tplidx = $pdf->importPage(1); $pdf->useImportedPage($tplIdx, 10, 10, 100); //$pdf->useTemplate($tplidx); $pdf->SetFont('Arial'); $pdf->SetFontSize(5); $pdf->SetXY(5, 5); $pdf->Text(3.5, 5, $_POST['A']); $pdf->Text(3.5, 8.5, $_POST['B']); $pdf->Text(21, 5, $_POST['C']); $pdf->Text(21, 8.3, $_POST['D']); $filename='SECONDTEST/'.$_POST['A'].'.pdf'; $pdf->Output($filename, 'F');
Advertisement
Answer
You are using the outdated version 1.x. useImportedPage()
was added in FPDI 2.