aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2010-08-05 23:06:49 +0200
committerJay Berkenbilt <ejb@ql.org>2010-08-05 23:06:49 +0200
commit2dbc1006fb4a176c6ca7418f6e6e27251a4b8142 (patch)
tree5b07158569cb28723ab37e43c727bc1df518cb3c /libqpdf
parentc29244296258b543edb3b276179c7d7444f65089 (diff)
downloadqpdf-2dbc1006fb4a176c6ca7418f6e6e27251a4b8142.tar.zst
addPageContents
git-svn-id: svn+q:///qpdf/trunk@995 71b93d88-0707-0410-a8cf-f5a4172ac649
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QPDFObjectHandle.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc
index 19b4f94e..143a3f42 100644
--- a/libqpdf/QPDFObjectHandle.cc
+++ b/libqpdf/QPDFObjectHandle.cc
@@ -472,6 +472,35 @@ QPDFObjectHandle::getPageContents()
return result;
}
+void
+QPDFObjectHandle::addPageContents(QPDFObjectHandle new_contents, bool first)
+{
+ assertPageObject();
+ new_contents.assertType("Stream", new_contents.isStream());
+
+ std::vector<QPDFObjectHandle> orig_contents = getPageContents();
+
+ std::vector<QPDFObjectHandle> content_streams;
+ if (first)
+ {
+ QTC::TC("qpdf", "QPDFObjectHandle prepend page contents");
+ content_streams.push_back(new_contents);
+ }
+ for (std::vector<QPDFObjectHandle>::iterator iter = orig_contents.begin();
+ iter != orig_contents.end(); ++iter)
+ {
+ QTC::TC("qpdf", "QPDFObjectHandle append page contents");
+ content_streams.push_back(*iter);
+ }
+ if (! first)
+ {
+ content_streams.push_back(new_contents);
+ }
+
+ QPDFObjectHandle contents = QPDFObjectHandle::newArray(content_streams);
+ this->replaceKey("/Contents", contents);
+}
+
std::string
QPDFObjectHandle::unparse()
{