0

So I'm creating a multiple page PDF with FPDI and I've encountered a problem when downloading and opening the PDF it creates. It displays and prints fine when viewing in Chrome or Firefox via their built in plug-ins. However in Adobe Reader or in IE it shows an error "There was a problem on this page" when I scroll down the pages.

I'm using FPDI to set a source file and the weird thing is that this displays fine. In this example I have 55 pages. It shows 55 pages with the source file I set but only the first page has the text I have set to PDF. The rest of the pages are just the source file. I'm guessing I am missing something that Adobe Reader doesn't like but I'm not sure what it is exactly!

   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");

    }

I've not attached all my code because content I've added is pretty much the same block of code just outputting a different field each time. I think the problem lies in the Create Page section but I'm not quite sure! I did try setting the ImportPage(1 to ImportPage($+1 but this gives me a FPDF error that the PageNumber is wrong

Thanks for your time and any help in advance
Jack

  • Are you using up to date versions of both [FPDI](http://www.setasign.com/products/fpdi/downloads/) and [FPDF](http://fpdf.org/en/download.php)? If not, update and try again. Otherwise it would be great to get access to the resulting document, that produces the error. Also the initial document is interresting. Did you opened it in Adobe Reader to see if the same error comes up? – Jan Slabon Oct 31 '14 at 09:36
  • Thanks for your response. I tried updating FPDI and FPDF but unfortantely the problem still occurs. The PDF includes other people's data so I can't really send it. I will replace this data with X's or something so you can at least see – Jack Handley Nov 01 '14 at 21:49
  • Does the error also occurs if you open the initial document(s) in Adobe Reader? – Jan Slabon Nov 02 '14 at 12:15

1 Answers1

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.