diff options
Diffstat (limited to 'libqpdf')
-rw-r--r-- | libqpdf/QPDFObjectHandle.cc | 29 |
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() { |