Skip to content

Commit

Permalink
Merge pull request #55 from aik099/20-gettext-maximum-function-nestin…
Browse files Browse the repository at this point in the history
…g-level-of-100-reached-aborting

Handle circular references in xObjects
  • Loading branch information
smalot committed Jan 21, 2015
2 parents 2ad086f + d5dd7a0 commit 91ed2b4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Smalot/PdfParser/Object.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ public function getText(Page $page = null)
$current_font = new Font($this->document);
$current_position_td = array('x' => false, 'y' => false);
$current_position_tm = array('x' => false, 'y' => false);
$object_hash = spl_object_hash($this);

foreach ($sections as $section) {

Expand Down Expand Up @@ -351,9 +352,12 @@ public function getText(Page $page = null)

case 'Do':
if (!is_null($page)) {
$args = preg_split('/\s/s', $command[self::COMMAND]);
$id = trim(array_pop($args), '/ ');
if ($xobject = $page->getXObject($id)) {
$args = preg_split('/\s/s', $command[self::COMMAND]);
$id = trim(array_pop($args), '/ ');
$xobject = $page->getXObject($id);

if ( is_object($xobject) && $object_hash !== spl_object_hash($xobject) ) {
// Not a circular reference.
$text .= $xobject->getText($page);
}
}
Expand Down

0 comments on commit 91ed2b4

Please sign in to comment.