TCPDF and FPDI with multiple pages

前端 未结 4 415
情话喂你
情话喂你 2020-12-09 23:45

This looks like the simplest thing but I can\'t get it to work.

I need to add text to the first page of a multi-page pdf (could be any number of pages)

Using

4条回答
  •  粉色の甜心
    2020-12-10 00:41

    that code wont work, try this:

    $pdf = new PDI();
    $pdf->AddPage();
    $pdf->setSourceFile('zzz.pdf');
    $pdf->numPages = $pdf->setSourceFile('zzz.pdf');
    $tplIdx = $pdf->importPage(1);
    $pdf->useTemplate($tplIdx, 10, 20, 200);
        if($pdf->numPages>1) {
    for($i=2;$i<=$pdf->numPages;$i++) {
        $pdf->AddPage();
        $tplIdx = $pdf->importPage($i);
        $pdf->useTemplate($tplIdx, 10, 20, 200);
    }
    }
    

提交回复
热议问题