From 009767d97a0dfebbb9bb71efb4b894b25fb59dd8 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Fri, 25 Jan 2019 06:55:31 -0500 Subject: Handle inheritable page attributes Add getAttribute for handling inheritable page attributes, and fix getPageImages and annotation flattening code to use it. --- libqpdf/QPDFObjectHandle.cc | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'libqpdf/QPDFObjectHandle.cc') diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index a0d45c86..b802a55c 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -1109,24 +1110,11 @@ QPDFObjectHandle::getGeneration() const std::map QPDFObjectHandle::getPageImages() { - // Note: this code doesn't handle inherited resources. If this - // page dictionary doesn't have a /Resources key or has one whose - // value is null or an empty dictionary, you are supposed to walk - // up the page tree until you find a /Resources dictionary. As of - // this writing, I don't have any test files that use inherited - // resources, and hand-generating one won't be a good test because - // any mistakes in my understanding would be present in both the - // code and the test file. - - // NOTE: If support of inherited resources (see above comment) is - // implemented, edit comment in QPDFObjectHandle.hh for this - // function. Also remove call to pushInheritedAttributesToPage - // from qpdf.cc when show_page_images is true. - std::map result; - if (this->hasKey("/Resources")) + QPDFObjectHandle resources = + QPDFPageObjectHelper(*this).getAttribute("/Resources", false); + if (resources.isDictionary()) { - QPDFObjectHandle resources = this->getKey("/Resources"); if (resources.hasKey("/XObject")) { QPDFObjectHandle xobject = resources.getKey("/XObject"); -- cgit v1.2.3-54-g00ecf