Skip to content

Commit

Permalink
Fix on Page->getText() and Page->getTextArray()
Browse files Browse the repository at this point in the history
In some PDFs, the content of the page is an instance of ElementNull, in those cases getText() and getTextArray() fails on getting the text: Call to undefined method Smalot\PdfParser\Element\ElementNull::getText()
  • Loading branch information
gbrlmza committed Sep 9, 2016
1 parent 3cd6697 commit 688e402
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Smalot/PdfParser/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use Smalot\PdfParser\Element\ElementArray;
use Smalot\PdfParser\Element\ElementMissing;
use Smalot\PdfParser\Element\ElementXRef;
use Smalot\PdfParser\Element\ElementNull;

/**
* Class Page
Expand Down Expand Up @@ -185,6 +186,8 @@ public function getText(Page $page = null)

if ($contents instanceof ElementMissing) {
return '';
} elseif ($contents instanceof ElementNull) {
return '';
} elseif ($contents instanceof Object) {
$elements = $contents->getHeader()->getElements();

Expand Down Expand Up @@ -231,6 +234,8 @@ public function getTextArray(Page $page = null)

if ($contents instanceof ElementMissing) {
return array();
} elseif ($contents instanceof ElementNull) {
return array();
} elseif ($contents instanceof Object) {
$elements = $contents->getHeader()->getElements();

Expand Down

0 comments on commit 688e402

Please sign in to comment.