aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2018-06-22 02:16:05 +0200
committerJay Berkenbilt <ejb@ql.org>2018-06-22 03:03:30 +0200
commit6c89d4b35bda528813b7ae9a39a1819af16a1fd0 (patch)
tree3479e54ecf1a6c547d76c092565a48609bb08847 /include
parentddd78c1b7f53f09710431d58cd94659271f325cc (diff)
downloadqpdf-6c89d4b35bda528813b7ae9a39a1819af16a1fd0.tar.zst
When splitting files, remove unreferenced objects (fixes #203)
Diffstat (limited to 'include')
-rw-r--r--include/qpdf/QPDFPageDocumentHelper.hh6
-rw-r--r--include/qpdf/QPDFPageObjectHelper.hh13
2 files changed, 19 insertions, 0 deletions
diff --git a/include/qpdf/QPDFPageDocumentHelper.hh b/include/qpdf/QPDFPageDocumentHelper.hh
index d7d4a026..5847e078 100644
--- a/include/qpdf/QPDFPageDocumentHelper.hh
+++ b/include/qpdf/QPDFPageDocumentHelper.hh
@@ -52,6 +52,12 @@ class QPDFPageDocumentHelper: public QPDFDocumentHelper
QPDF_DLL
void pushInheritedAttributesToPage();
+ // This calls QPDFPageObjectHelper::removeUnreferencedResources
+ // for every page in the document. See comments in
+ // QPDFPageObjectHelper.hh for details.
+ QPDF_DLL
+ void removeUnreferencedResources();
+
// Add new page at the beginning or the end of the current pdf.
// The newpage parameter may be either a direct object, an
// indirect object from this QPDF, or an indirect object from
diff --git a/include/qpdf/QPDFPageObjectHelper.hh b/include/qpdf/QPDFPageObjectHelper.hh
index 9226a748..570e81b4 100644
--- a/include/qpdf/QPDFPageObjectHelper.hh
+++ b/include/qpdf/QPDFPageObjectHelper.hh
@@ -122,6 +122,19 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
void addContentTokenFilter(
PointerHolder<QPDFObjectHandle::TokenFilter> token_filter);
+ // A page's resources dictionary maps names to objects elsewhere
+ // in the file. This method walks through a page's contents and
+ // keeps tracks of which resources are referenced somewhere in the
+ // contents. Then it removes from the resources dictionary any
+ // object that is not referenced in the contents. This operation
+ // is most useful after calling
+ // QPDFPageDocumentHelper::pushInheritedAttributesToPage(). This
+ // method is used by page splitting code to avoid copying unused
+ // objects in files that used shared resource dictionaries across
+ // multiple pages.
+ QPDF_DLL
+ void removeUnreferencedResources();
+
private:
class Members
{