为什么FPDF的useImportedPage无法用于PHP代码

时间:2019-09-25 14:09:31

标签: php fpdf fpdi

使用useImportedPage()生成标签时收到以下错误...

  

ErrorException [致命错误]:调用未定义的方法   FPDI :: useImportedPage()。

但是当我注释$pdf->useImportedPage($tplIdx, 10, 10, 100);时 并取消注释行$pdf->useTemplate($tplidx);的效果。

我导入的PDF版本为1.4。

关于useImportedPage()为什么不起作用的任何建议?

    $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');

1 个答案:

答案 0 :(得分:1)

您正在使用过时的版本1.x。 useImportedPage()已添加到FPDI 2中。