diff options
author | Jay Berkenbilt <ejb@ql.org> | 2021-02-21 01:16:40 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2021-02-21 01:42:41 +0100 |
commit | 05eb5826d8b8beb19e8ec65915af1476e7dd1db3 (patch) | |
tree | 42ab5bf65b78a24a06182089d0f54b4a88256aab | |
parent | 3aefdd18a6ca7c2e04cac58ff63fbe9231edc25f (diff) | |
download | qpdf-05eb5826d8b8beb19e8ec65915af1476e7dd1db3.tar.zst |
Fix isPagesObject and isPageObject
There are lots of things with /Kids that are not pages. Repair the
pages tree, then do a reliable check.
-rw-r--r-- | libqpdf/QPDFObjectHandle.cc | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index b0ae75f1..6c37829d 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -3039,6 +3039,12 @@ bool QPDFObjectHandle::isPageObject() { // See comments in QPDFObjectHandle.hh. + if (getOwningQPDF() == nullptr) + { + return false; + } + // getAllPages repairs /Type when traversing the page tree. + getOwningQPDF()->getAllPages(); if (! this->isDictionary()) { return false; @@ -3066,8 +3072,16 @@ QPDFObjectHandle::isPageObject() bool QPDFObjectHandle::isPagesObject() { - // Some PDF files have /Type broken on pages. - return (this->isDictionary() && this->hasKey("/Kids")); + if (getOwningQPDF() == nullptr) + { + return false; + } + // getAllPages repairs /Type when traversing the page tree. + getOwningQPDF()->getAllPages(); + return (this->isDictionary() && + this->hasKey("/Type") && + this->getKey("/Type").isName() && + this->getKey("/Type").getName() == "/Pages"); } bool |