aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFPageDocumentHelper.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2019-01-03 17:51:58 +0100
committerJay Berkenbilt <ejb@ql.org>2019-01-03 17:59:55 +0100
commitca94ac68d9cdb317328398c770c9c755f0004535 (patch)
tree1654a22747dcf94151efa61ce62eda7ff7e967d0 /libqpdf/QPDFPageDocumentHelper.cc
parent06d6438ddf7f817d9cc1698c9b4b5e4b8f53e151 (diff)
downloadqpdf-ca94ac68d9cdb317328398c770c9c755f0004535.tar.zst
Honor flags when flattening annotations
Diffstat (limited to 'libqpdf/QPDFPageDocumentHelper.cc')
-rw-r--r--libqpdf/QPDFPageDocumentHelper.cc30
1 files changed, 21 insertions, 9 deletions
diff --git a/libqpdf/QPDFPageDocumentHelper.cc b/libqpdf/QPDFPageDocumentHelper.cc
index d168f8de..1dacd672 100644
--- a/libqpdf/QPDFPageDocumentHelper.cc
+++ b/libqpdf/QPDFPageDocumentHelper.cc
@@ -68,7 +68,9 @@ QPDFPageDocumentHelper::removePage(QPDFPageObjectHelper page)
void
-QPDFPageDocumentHelper::flattenAnnotations()
+QPDFPageDocumentHelper::flattenAnnotations(
+ int required_flags,
+ int forbidden_flags)
{
QPDFAcroFormDocumentHelper afdh(this->qpdf);
if (afdh.getNeedAppearances())
@@ -97,7 +99,8 @@ QPDFPageDocumentHelper::flattenAnnotations()
// test suite
resources = QPDFObjectHandle::newDictionary();
}
- flattenAnnotationsForPage(ph, resources, afdh);
+ flattenAnnotationsForPage(ph, resources, afdh,
+ required_flags, forbidden_flags);
}
if (! afdh.getNeedAppearances())
{
@@ -109,7 +112,9 @@ void
QPDFPageDocumentHelper::flattenAnnotationsForPage(
QPDFPageObjectHelper& page,
QPDFObjectHandle& resources,
- QPDFAcroFormDocumentHelper& afdh)
+ QPDFAcroFormDocumentHelper& afdh,
+ int required_flags,
+ int forbidden_flags)
{
bool need_appearances = afdh.getNeedAppearances();
std::vector<QPDFAnnotationObjectHelper> annots = page.getAnnotations();
@@ -168,12 +173,12 @@ QPDFPageDocumentHelper::flattenAnnotationsForPage(
while (next_fx <= max_fx)
{
std::string candidate = "/Fxo" + QUtil::int_to_string(next_fx);
- ++next_fx;
if (names.count(candidate) == 0)
{
name = candidate;
break;
}
+ ++next_fx;
}
if (name.empty())
{
@@ -182,11 +187,18 @@ QPDFPageDocumentHelper::flattenAnnotationsForPage(
// number of keys we're checking against.
name = "/FxConflict";
}
- resources.mergeResources(
- QPDFObjectHandle::parse(
- "<< /XObject << " + name + " null >> >>"));
- resources.getKey("/XObject").replaceKey(name, as);
- new_content += aoh.getPageContentForAppearance(name, rotate);
+ std::string content = aoh.getPageContentForAppearance(
+ name, rotate, required_flags, forbidden_flags);
+ if (! content.empty())
+ {
+ resources.mergeResources(
+ QPDFObjectHandle::parse(
+ "<< /XObject << " + name + " null >> >>"));
+ resources.getKey("/XObject").replaceKey(name, as);
+ names.insert(name);
+ ++next_fx;
+ }
+ new_content += content;
}
else
{