I'm trying to import a pdf with php class FPDI with this simple code:
require_once("fpdf/fpdf.php");
require_once("fpdi/fpdi.php");
$pdf = new FPDI();
$pdf->setSourceFile('intermedia.pdf');
$tplidx = $pdf->ImportPage(1);
$pdf->AddPage();
$pdf->useTemplate($tplidx,0,0,210);
$pdf->Output();
but I receive the following error:
Warning: explode() [function.explode]: Empty delimiter. in /var/catalogo/test_pdf/fpdi/pdf_parser.php on line 369
Fatal error: Uncaught exception 'Exception' with message 'Unable to find object (1, 0) at expected location.' in /var/catalogo/test_pdf/fpdi/pdf_parser.php:709 Stack trace: #0 /var/catalogo/test_pdf/fpdi/pdf_parser.php(268): pdf_parser->resolveObject(Array) #1 /var/catalogo/test_pdf/fpdi/pdf_parser.php(208): pdf_parser->_readRoot() #2 /var/catalogo/test_pdf/fpdi/fpdi_pdf_parser.php(71): pdf_parser->__construct('/var/catalogo/t...') #3 /var/catalogo/test_pdf/fpdi/fpdi.php(128): fpdi_pdf_parser->__construct('/var/catalogo/t...') #4 /var/catalogo/test_pdf/fpdi/fpdi.php(108): FPDI->_getPdfParser('/var/catalogo/t...') #5 /var/catalogo/test_pdf/index.php(5): FPDI->setSourceFile('intermedia.pdf') #6 {main} thrown in /var/catalogo/test_pdf/fpdi/pdf_parser.php on line 709
This is the file that should be imported: http://catalogo.selectaspa.it/test_pdf/intermedia.pdf
Ok, the cross reference of this file is simply corrupted. I just catched the "Warning" on explode for now but at the end you will have to resave the document with e.g. Acrobat to repair it before passing it to FPDI.
You may change pdf_parser.php around line 362 to:
Same fix can be used in the separate FPDI PDF-Parser which will allow you to read this document then, too.