pdfparser icon indicating copy to clipboard operation
pdfparser copied to clipboard

Uncaught Error: Call to a member function getPages() on null

Open chris087 opened this issue 6 years ago • 3 comments

A lot of PDFs (not all...) gives an Error (PHP 7, PHP 7.2 + 7.3)

Uncaught Error: Call to a member function getPages() on null

  1. Download this test PDF: http://www.orimi.com/pdf-test.pdf
  2. save to disk

3 run:

$parser = new \Smalot\PdfParser\Parser();  

try {        

    $pdf = $parser->parseFile($file);

} catch(Exception $e) {

}  
  // echo '<pre>';
  // print_r($pdf);
  // exit;
   
// Retrieve all pages from the pdf file.
**$pages  = $pdf->getPages();**   >>> ERROR
$pageNr = 1;

chris087 avatar Mar 25 '19 09:03 chris087

I saved your PDF here, just in case. pdf-test.pdf

As you might already figured, it couldn't parse the file and returns null instead of an object to work with. Unfortunately I can't help you with that.

k00ni avatar Jul 08 '20 07:07 k00ni

PdfParser now returns a "Secured PDF" exception for this document.

Fatal error:  Uncaught Exception: Secured pdf file are currently not supported. in 
/***/pdfparser/src/Smalot/PdfParser/Parser.php:105

So does that resolve this issue, or... ?

GreyWyvern avatar Jul 21 '23 14:07 GreyWyvern

@chris087 is it a secured PDF?

k00ni avatar Jul 23 '23 15:07 k00ni