0

因此,我正在使用 FPDI 创建多页 PDF,但在下载和打开它创建的 PDF 时遇到了问题。通过其内置插件在 Chrome 或 Firefox 中查看时,它可以正常显示和打印。但是在 Adob​​e Reader 或 IE 中,当我向下滚动页面时,它会显示错误“此页面上有问题”。

我正在使用 FPDI 设置源文件,奇怪的是它显示得很好。在这个例子中,我有 55 页。它显示了我设置的源文件的 55 页,但只有第一页有我设置为 PDF 的文本。其余页面只是源文件。我猜我错过了 Adob​​e Reader 不喜欢的东西,但我不确定它到底是什么!

   require_once('/data/functions/pdfs/fpdf/fpdf.php');
   require_once('/data/functions/pdfs/fpdi/fpdi.php');
   require_once('rotate.php');
   $pdf=new PDF(); 

    $pagecount = $pdf->setSourceFile('EIBTM14_Exhibitor_Badge.pdf');

    for($i = 0; $i < $num_badges; $i++)
    {
        //Create Page
        $thePage = $pdf->importPage(1, '/MediaBox');
        $pdf->addPage();
        $pdf->useTemplate($thePage,0,0,0,false);

        //Content of each page
        $pdf->SetXY(141,197);
        $pdf->Rotate(90);
        $pdf->SetFont('Arial','',fontsize($company));
        $pdf->Cell(-100,13,mb_strtoupper($company),$borders,1,"C");

    }

我没有附加我所有的代码,因为我添加的内容几乎是相同的代码块,只是每次输出不同的字段。我认为问题出在“创建页面”部分,但我不太确定!我确实尝试将 ImportPage(1 设置为 ImportPage($+1 但这给了我一个 FPDF 错误,即 PageNumber 错误

感谢您的时间和任何提前帮助
杰克

4

1 回答 1

0

Doh! I've managed to get some time to look into this properly and it turns out it was the rotation breaking it. I needed to reset the rotation back to 0 before adding a new page i.e.

$pdf->Rotate(0);
$pdf->addPage();

Thanks for your help on this just needed some time to break it up piece by piece to see what was causing the error.

于 2014-11-10T12:32:26.660 回答