mirror of
https://github.com/qpdf/qpdf.git
synced 2025-02-07 06:08:26 +00:00
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.
This commit is contained in:
parent
85f70cae23
commit
65ef0bf313
@ -1,3 +1,10 @@
|
||||
2019-01-20 Jay Berkenbilt <ejb@ql.org>
|
||||
|
||||
* When flattening annotations, remove annotations from the file
|
||||
that don't have appearance streams. These were previously being
|
||||
preserved, but since they are invisible, there is no reason to
|
||||
preserve them when flattening annotations.
|
||||
|
||||
2019-01-19 Jay Berkenbilt <ejb@ql.org>
|
||||
|
||||
* NOTE: qpdf CLI: some non-compatible changes were made to how
|
||||
|
@ -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());
|
||||
|
@ -421,3 +421,4 @@ qpdf auto-encode password 0
|
||||
qpdf bytes fallback warning 0
|
||||
qpdf invalid utf-8 in auto 0
|
||||
qpdf input password hex-bytes 0
|
||||
QPDFPageDocumentHelper ignore annotation with no appearance 0
|
||||
|
@ -1609,6 +1609,7 @@ my @annotation_files = (
|
||||
'comment-annotation-direct',
|
||||
'sample-form',
|
||||
'need-appearances',
|
||||
'need-appearances-more',
|
||||
);
|
||||
$n_tests += 2 * scalar(@annotation_files);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -22,13 +22,10 @@ endobj
|
||||
%% Page 1
|
||||
3 0 obj
|
||||
<<
|
||||
/Annots [
|
||||
4 0 R
|
||||
]
|
||||
/Contents [
|
||||
5 0 R
|
||||
7 0 R
|
||||
9 0 R
|
||||
4 0 R
|
||||
6 0 R
|
||||
8 0 R
|
||||
]
|
||||
/MediaBox [
|
||||
0
|
||||
@ -39,51 +36,35 @@ endobj
|
||||
/Parent 2 0 R
|
||||
/Resources <<
|
||||
/Font <<
|
||||
/F1 11 0 R
|
||||
/F1 10 0 R
|
||||
>>
|
||||
/ProcSet 12 0 R
|
||||
/ProcSet 11 0 R
|
||||
/XObject <<
|
||||
/Fxo1 13 0 R
|
||||
/Fxo1 12 0 R
|
||||
>>
|
||||
>>
|
||||
/Type /Page
|
||||
>>
|
||||
endobj
|
||||
|
||||
%% Contents for page 1
|
||||
4 0 obj
|
||||
<<
|
||||
/F 28
|
||||
/Open false
|
||||
/Parent 15 0 R
|
||||
/Rect [
|
||||
612
|
||||
601
|
||||
792
|
||||
721
|
||||
]
|
||||
/Subtype /Popup
|
||||
/Type /Annot
|
||||
>>
|
||||
endobj
|
||||
|
||||
%% Contents for page 1
|
||||
5 0 obj
|
||||
<<
|
||||
/Length 6 0 R
|
||||
/Length 5 0 R
|
||||
>>
|
||||
stream
|
||||
q
|
||||
endstream
|
||||
endobj
|
||||
|
||||
6 0 obj
|
||||
5 0 obj
|
||||
2
|
||||
endobj
|
||||
|
||||
%% Contents for page 1
|
||||
7 0 obj
|
||||
6 0 obj
|
||||
<<
|
||||
/Length 8 0 R
|
||||
/Length 7 0 R
|
||||
>>
|
||||
stream
|
||||
BT
|
||||
@ -94,14 +75,14 @@ ET
|
||||
endstream
|
||||
endobj
|
||||
|
||||
8 0 obj
|
||||
7 0 obj
|
||||
44
|
||||
endobj
|
||||
|
||||
%% Contents for page 1
|
||||
9 0 obj
|
||||
8 0 obj
|
||||
<<
|
||||
/Length 10 0 R
|
||||
/Length 9 0 R
|
||||
>>
|
||||
stream
|
||||
|
||||
@ -113,11 +94,11 @@ Q
|
||||
endstream
|
||||
endobj
|
||||
|
||||
10 0 obj
|
||||
9 0 obj
|
||||
71
|
||||
endobj
|
||||
|
||||
11 0 obj
|
||||
10 0 obj
|
||||
<<
|
||||
/BaseFont /Helvetica
|
||||
/Encoding /WinAnsiEncoding
|
||||
@ -127,14 +108,14 @@ endobj
|
||||
>>
|
||||
endobj
|
||||
|
||||
12 0 obj
|
||||
11 0 obj
|
||||
[
|
||||
/PDF
|
||||
/Text
|
||||
]
|
||||
endobj
|
||||
|
||||
13 0 obj
|
||||
12 0 obj
|
||||
<<
|
||||
/BBox [
|
||||
0
|
||||
@ -155,7 +136,7 @@ endobj
|
||||
>>
|
||||
/Subtype /Form
|
||||
/Type /XObject
|
||||
/Length 14 0 R
|
||||
/Length 13 0 R
|
||||
>>
|
||||
stream
|
||||
q 1 1 1 rg 0 i 1 w 4 M 1 j 0 J []0 d /GS0 gs 1 0 0 1 9 5.0908 cm 7.74 12.616 m -7.74 12.616 l -8.274 12.616 -8.707 12.184 -8.707 11.649 c -8.707 -3.831 l -8.707 -4.365 -8.274 -4.798 -7.74 -4.798 c 7.74 -4.798 l 8.274 -4.798 8.707 -4.365 8.707 -3.831 c 8.707 11.649 l 8.707 12.184 8.274 12.616 7.74 12.616 c h f Q 0 G 1 1 0 rg 0 i 0.60 w 4 M 1 j 0 J []0 d 1 1 0 rg 0 G 0 i 0.59 w 4 M 1 j 0 J []0 d 1 0 0 1 9 5.0908 cm 0 0 m -0.142 0 -0.28 0.008 -0.418 0.015 c -2.199 -1.969 -5.555 -2.242 -4.642 -1.42 c -4.024 -0.862 -3.916 0.111 -3.954 0.916 c -5.658 1.795 -6.772 3.222 -6.772 4.839 c -6.772 7.509 -3.74 9.674 0 9.674 c 3.74 9.674 6.772 7.509 6.772 4.839 c 6.772 2.167 3.74 0 0 0 c 7.74 12.616 m -7.74 12.616 l -8.274 12.616 -8.707 12.184 -8.707 11.649 c -8.707 -3.831 l -8.707 -4.365 -8.274 -4.798 -7.74 -4.798 c 7.74 -4.798 l 8.274 -4.798 8.707 -4.365 8.707 -3.831 c 8.707 11.649 l 8.707 12.184 8.274 12.616 7.74 12.616 c b
|
||||
@ -163,63 +144,31 @@ endstream
|
||||
endobj
|
||||
|
||||
%QDF: ignore_newline
|
||||
14 0 obj
|
||||
13 0 obj
|
||||
928
|
||||
endobj
|
||||
|
||||
15 0 obj
|
||||
<<
|
||||
/AP <<
|
||||
/N 13 0 R
|
||||
>>
|
||||
/C [
|
||||
1
|
||||
1
|
||||
0
|
||||
]
|
||||
/CA 1
|
||||
/Contents (Salad)
|
||||
/CreationDate (D:20181231235455Z00'00)
|
||||
/F 28
|
||||
/M (D:20181231235455Z00'00)
|
||||
/Name /Comment
|
||||
/P 3 0 R
|
||||
/Popup 4 0 R
|
||||
/Rect [
|
||||
235
|
||||
703
|
||||
253
|
||||
721
|
||||
]
|
||||
/Subtype /Text
|
||||
/T (Jay Berkenbilt)
|
||||
/Type /Annot
|
||||
>>
|
||||
endobj
|
||||
|
||||
xref
|
||||
0 16
|
||||
0 14
|
||||
0000000000 65535 f
|
||||
0000000025 00000 n
|
||||
0000000079 00000 n
|
||||
0000000161 00000 n
|
||||
0000000453 00000 n
|
||||
0000000616 00000 n
|
||||
0000000673 00000 n
|
||||
0000000714 00000 n
|
||||
0000000813 00000 n
|
||||
0000000855 00000 n
|
||||
0000000982 00000 n
|
||||
0000001002 00000 n
|
||||
0000001121 00000 n
|
||||
0000001157 00000 n
|
||||
0000002401 00000 n
|
||||
0000002422 00000 n
|
||||
0000000450 00000 n
|
||||
0000000507 00000 n
|
||||
0000000548 00000 n
|
||||
0000000647 00000 n
|
||||
0000000689 00000 n
|
||||
0000000815 00000 n
|
||||
0000000834 00000 n
|
||||
0000000953 00000 n
|
||||
0000000989 00000 n
|
||||
0000002233 00000 n
|
||||
trailer <<
|
||||
/Root 1 0 R
|
||||
/Size 16
|
||||
/Size 14
|
||||
/ID [<c5b1999a07a3fdcd0c04cfeed299c25a><31415926535897932384626433832795>]
|
||||
>>
|
||||
startxref
|
||||
2752
|
||||
2254
|
||||
%%EOF
|
||||
|
@ -22,11 +22,10 @@ endobj
|
||||
%% Page 1
|
||||
3 0 obj
|
||||
<<
|
||||
/Annots 4 0 R
|
||||
/Contents [
|
||||
5 0 R
|
||||
7 0 R
|
||||
9 0 R
|
||||
4 0 R
|
||||
6 0 R
|
||||
8 0 R
|
||||
]
|
||||
/MediaBox [
|
||||
0
|
||||
@ -37,41 +36,35 @@ endobj
|
||||
/Parent 2 0 R
|
||||
/Resources <<
|
||||
/Font <<
|
||||
/F1 11 0 R
|
||||
/F1 10 0 R
|
||||
>>
|
||||
/ProcSet 12 0 R
|
||||
/ProcSet 11 0 R
|
||||
/XObject <<
|
||||
/Fxo1 13 0 R
|
||||
/Fxo1 12 0 R
|
||||
>>
|
||||
>>
|
||||
/Type /Page
|
||||
>>
|
||||
endobj
|
||||
|
||||
4 0 obj
|
||||
[
|
||||
15 0 R
|
||||
]
|
||||
endobj
|
||||
|
||||
%% Contents for page 1
|
||||
5 0 obj
|
||||
4 0 obj
|
||||
<<
|
||||
/Length 6 0 R
|
||||
/Length 5 0 R
|
||||
>>
|
||||
stream
|
||||
q
|
||||
endstream
|
||||
endobj
|
||||
|
||||
6 0 obj
|
||||
5 0 obj
|
||||
2
|
||||
endobj
|
||||
|
||||
%% Contents for page 1
|
||||
7 0 obj
|
||||
6 0 obj
|
||||
<<
|
||||
/Length 8 0 R
|
||||
/Length 7 0 R
|
||||
>>
|
||||
stream
|
||||
BT
|
||||
@ -82,14 +75,14 @@ ET
|
||||
endstream
|
||||
endobj
|
||||
|
||||
8 0 obj
|
||||
7 0 obj
|
||||
44
|
||||
endobj
|
||||
|
||||
%% Contents for page 1
|
||||
9 0 obj
|
||||
8 0 obj
|
||||
<<
|
||||
/Length 10 0 R
|
||||
/Length 9 0 R
|
||||
>>
|
||||
stream
|
||||
|
||||
@ -101,11 +94,11 @@ Q
|
||||
endstream
|
||||
endobj
|
||||
|
||||
10 0 obj
|
||||
9 0 obj
|
||||
71
|
||||
endobj
|
||||
|
||||
11 0 obj
|
||||
10 0 obj
|
||||
<<
|
||||
/BaseFont /Helvetica
|
||||
/Encoding /WinAnsiEncoding
|
||||
@ -115,14 +108,14 @@ endobj
|
||||
>>
|
||||
endobj
|
||||
|
||||
12 0 obj
|
||||
11 0 obj
|
||||
[
|
||||
/PDF
|
||||
/Text
|
||||
]
|
||||
endobj
|
||||
|
||||
13 0 obj
|
||||
12 0 obj
|
||||
<<
|
||||
/BBox [
|
||||
0
|
||||
@ -143,7 +136,7 @@ endobj
|
||||
>>
|
||||
/Subtype /Form
|
||||
/Type /XObject
|
||||
/Length 14 0 R
|
||||
/Length 13 0 R
|
||||
>>
|
||||
stream
|
||||
q 1 1 1 rg 0 i 1 w 4 M 1 j 0 J []0 d /GS0 gs 1 0 0 1 9 5.0908 cm 7.74 12.616 m -7.74 12.616 l -8.274 12.616 -8.707 12.184 -8.707 11.649 c -8.707 -3.831 l -8.707 -4.365 -8.274 -4.798 -7.74 -4.798 c 7.74 -4.798 l 8.274 -4.798 8.707 -4.365 8.707 -3.831 c 8.707 11.649 l 8.707 12.184 8.274 12.616 7.74 12.616 c h f Q 0 G 1 1 0 rg 0 i 0.60 w 4 M 1 j 0 J []0 d 1 1 0 rg 0 G 0 i 0.59 w 4 M 1 j 0 J []0 d 1 0 0 1 9 5.0908 cm 0 0 m -0.142 0 -0.28 0.008 -0.418 0.015 c -2.199 -1.969 -5.555 -2.242 -4.642 -1.42 c -4.024 -0.862 -3.916 0.111 -3.954 0.916 c -5.658 1.795 -6.772 3.222 -6.772 4.839 c -6.772 7.509 -3.74 9.674 0 9.674 c 3.74 9.674 6.772 7.509 6.772 4.839 c 6.772 2.167 3.74 0 0 0 c 7.74 12.616 m -7.74 12.616 l -8.274 12.616 -8.707 12.184 -8.707 11.649 c -8.707 -3.831 l -8.707 -4.365 -8.274 -4.798 -7.74 -4.798 c 7.74 -4.798 l 8.274 -4.798 8.707 -4.365 8.707 -3.831 c 8.707 11.649 l 8.707 12.184 8.274 12.616 7.74 12.616 c b
|
||||
@ -151,80 +144,31 @@ endstream
|
||||
endobj
|
||||
|
||||
%QDF: ignore_newline
|
||||
14 0 obj
|
||||
13 0 obj
|
||||
928
|
||||
endobj
|
||||
|
||||
15 0 obj
|
||||
<<
|
||||
/F 28
|
||||
/Open false
|
||||
/Parent 16 0 R
|
||||
/Rect [
|
||||
612
|
||||
601
|
||||
792
|
||||
721
|
||||
]
|
||||
/Subtype /Popup
|
||||
/Type /Annot
|
||||
>>
|
||||
endobj
|
||||
|
||||
16 0 obj
|
||||
<<
|
||||
/AP <<
|
||||
/N 13 0 R
|
||||
>>
|
||||
/C [
|
||||
1
|
||||
1
|
||||
0
|
||||
]
|
||||
/CA 1
|
||||
/Contents (Salad)
|
||||
/CreationDate (D:20181231235455Z00'00)
|
||||
/F 28
|
||||
/M (D:20181231235455Z00'00)
|
||||
/Name /Comment
|
||||
/P 3 0 R
|
||||
/Popup 15 0 R
|
||||
/Rect [
|
||||
235
|
||||
703
|
||||
253
|
||||
721
|
||||
]
|
||||
/Subtype /Text
|
||||
/T (Jay Berkenbilt)
|
||||
/Type /Annot
|
||||
>>
|
||||
endobj
|
||||
|
||||
xref
|
||||
0 17
|
||||
0 14
|
||||
0000000000 65535 f
|
||||
0000000025 00000 n
|
||||
0000000079 00000 n
|
||||
0000000161 00000 n
|
||||
0000000443 00000 n
|
||||
0000000495 00000 n
|
||||
0000000552 00000 n
|
||||
0000000593 00000 n
|
||||
0000000692 00000 n
|
||||
0000000734 00000 n
|
||||
0000000861 00000 n
|
||||
0000000881 00000 n
|
||||
0000001000 00000 n
|
||||
0000001036 00000 n
|
||||
0000002280 00000 n
|
||||
0000002301 00000 n
|
||||
0000002442 00000 n
|
||||
0000000450 00000 n
|
||||
0000000507 00000 n
|
||||
0000000548 00000 n
|
||||
0000000647 00000 n
|
||||
0000000689 00000 n
|
||||
0000000815 00000 n
|
||||
0000000834 00000 n
|
||||
0000000953 00000 n
|
||||
0000000989 00000 n
|
||||
0000002233 00000 n
|
||||
trailer <<
|
||||
/Root 1 0 R
|
||||
/Size 17
|
||||
/Size 14
|
||||
/ID [<c5b1999a07a3fdcd0c04cfeed299c25a><31415926535897932384626433832795>]
|
||||
>>
|
||||
startxref
|
||||
2773
|
||||
2254
|
||||
%%EOF
|
||||
|
3724
qpdf/qtest/qpdf/need-appearances-more-out.pdf
Normal file
3724
qpdf/qtest/qpdf/need-appearances-more-out.pdf
Normal file
File diff suppressed because it is too large
Load Diff
2
qpdf/qtest/qpdf/need-appearances-more-warn.out
Normal file
2
qpdf/qtest/qpdf/need-appearances-more-warn.out
Normal file
@ -0,0 +1,2 @@
|
||||
WARNING: need-appearances-more.pdf, object 1 0 at offset 50: document does not have updated appearance streams, so form fields will not be flattened
|
||||
qpdf: operation succeeded with warnings; resulting file may have some problems
|
3779
qpdf/qtest/qpdf/need-appearances-more.pdf
Normal file
3779
qpdf/qtest/qpdf/need-appearances-more.pdf
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1408,12 +1408,6 @@ endobj
|
||||
%% Page 1
|
||||
45 0 obj
|
||||
<<
|
||||
/Annots [
|
||||
15 0 R
|
||||
17 0 R
|
||||
18 0 R
|
||||
19 0 R
|
||||
]
|
||||
/Contents [
|
||||
78 0 R
|
||||
80 0 R
|
||||
@ -2751,10 +2745,12 @@ endobj
|
||||
>>
|
||||
stream
|
||||
|