diff --git a/lib/PDF/API2.pm b/lib/PDF/API2.pm index 14a4a7b0..b6de9a87 100644 --- a/lib/PDF/API2.pm +++ b/lib/PDF/API2.pm @@ -906,7 +906,7 @@ sub proc_pages { $pdf->{' apipagecount'} ||= 0; foreach my $page ($object->{'Kids'}->elements()) { $page->realise(); - if ($page->{'Type'}->val() eq 'Pages') { + if (defined $page->{'Type'} && $page->{'Type'}->val() eq 'Pages') { push @pages, proc_pages($pdf, $page); } else { diff --git a/lib/PDF/API2/Basic/PDF/Dict.pm b/lib/PDF/API2/Basic/PDF/Dict.pm index 3e731333..7663d7fb 100644 --- a/lib/PDF/API2/Basic/PDF/Dict.pm +++ b/lib/PDF/API2/Basic/PDF/Dict.pm @@ -82,6 +82,30 @@ sub type { return $self->{'Type'}->val(); } +=head2 $p->find_prop($key) + +Searches up through the inheritance tree to find a property. + +=cut + +sub find_prop { + my ($self, $prop) = @_; + + if (defined $self->{$prop}) { + if (ref($self->{$prop}) and $self->{$prop}->isa('PDF::API2::Basic::PDF::Objind')) { + return $self->{$prop}->realise(); + } + else { + return $self->{$prop}; + } + } + elsif (defined $self->{'Parent'}) { + return $self->{'Parent'}->find_prop($prop); + } + + return; +} + =head2 @filters = $d->filter(@filters) Get/Set one or more filters being used by the optional stream attached to the dictionary.