aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFPageDocumentHelper.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2019-01-21 02:40:56 +0100
committerJay Berkenbilt <ejb@ql.org>2019-01-21 05:05:58 +0100
commit65ef0bf3130b69c8d48181ab27688567535f2d9f (patch)
treec28c260ab89427e5401511c43f363892a52fda9d /libqpdf/QPDFPageDocumentHelper.cc
parent85f70cae2365b30474d2c5640101960b82488c71 (diff)
downloadqpdf-65ef0bf3130b69c8d48181ab27688567535f2d9f.tar.zst
When flattening, remove annotations with no appearance stream
With the exception of form field annotations when /NeedAppearances is true, remove annotations that don't have appearance streams when flattening. There is no reason to keep these when flattening since they are invisible. This may include unchecked checkboxes, unshown popup windows, etc.
Diffstat (limited to 'libqpdf/QPDFPageDocumentHelper.cc')
-rw-r--r--libqpdf/QPDFPageDocumentHelper.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/libqpdf/QPDFPageDocumentHelper.cc b/libqpdf/QPDFPageDocumentHelper.cc
index 1dacd672..fa50c471 100644
--- a/libqpdf/QPDFPageDocumentHelper.cc
+++ b/libqpdf/QPDFPageDocumentHelper.cc
@@ -141,11 +141,7 @@ QPDFPageDocumentHelper::flattenAnnotationsForPage(
QTC::TC("qpdf", "QPDFPageDocumentHelper skip widget need appearances");
process = false;
}
- if (process && (! as.isStream()))
- {
- process = false;
- }
- if (process)
+ if (process && as.isStream())
{
if (is_widget)
{
@@ -200,6 +196,15 @@ QPDFPageDocumentHelper::flattenAnnotationsForPage(
}
new_content += content;
}
+ else if (process)
+ {
+ // If an annotation has no appearance stream, just drop
+ // the annotation when flattening. This can happen for
+ // unchecked checkboxes and radio buttons, popup windows
+ // associated with comments that aren't visible, and other
+ // types of annotations that aren't visible.
+ QTC::TC("qpdf", "QPDFPageDocumentHelper ignore annotation with no appearance");
+ }
else
{
new_annots.push_back(aoh.getObjectHandle());