我是 PHP 新手,在插入多个页面时使用 FPDI 有点困难。
我有一个由 3 页组成的 .pdf 文件。我最终将第 1 页保存为 3 页中的单独页面,并且可以与我的代码一起使用,但那是因为我的代码仅适用于 1 页。当我将它改回 3 页文件时,它给了我一个内部服务器错误。
这是我正在使用的代码:
<?php
require_once('prog/fpdf.php');
require_once('prog/fpdi.php');
// initiate FPDI
$pdf = new FPDI();
// add a page
$pdf->AddPage();
// set the source file
$pdf->setSourceFile("apps/Par.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, null, null, 0, 0, true);
// font and color selection
$pdf->SetFont('Helvetica');
$pdf->SetTextColor(200, 0, 0);
// now write some text above the imported page
$pdf->SetXY(40, 83);
$pdf->Write(2, 'THIS IS JUST A TEST');
$pdf->Output();
我不知道如何把这段代码变成能够看到所有 3 页的能力。请帮助我。