aboutsummaryrefslogtreecommitdiffstats
path: root/qpdf/qtest/flatten-annotations.test
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-05-19 23:27:41 +0200
committerJay Berkenbilt <ejb@ql.org>2022-05-20 15:16:25 +0200
commit6c5e590673331aa685afe8aa997b0b7e64996004 (patch)
tree66f14ee6b4a5bb6bc1f6bfa006d40ec9c8760b74 /qpdf/qtest/flatten-annotations.test
parent6f43bf8de36b08c55b172b4f4133c79657651666 (diff)
downloadqpdf-6c5e590673331aa685afe8aa997b0b7e64996004.tar.zst
Rename all test files: _ to -
Diffstat (limited to 'qpdf/qtest/flatten-annotations.test')
-rw-r--r--qpdf/qtest/flatten-annotations.test94
1 files changed, 94 insertions, 0 deletions
diff --git a/qpdf/qtest/flatten-annotations.test b/qpdf/qtest/flatten-annotations.test
new file mode 100644
index 00000000..5d071dba
--- /dev/null
+++ b/qpdf/qtest/flatten-annotations.test
@@ -0,0 +1,94 @@
+#!/usr/bin/env perl
+require 5.008;
+use warnings;
+use strict;
+
+unshift(@INC, '.');
+require qpdf_test_helpers;
+
+chdir("qpdf") or die "chdir testdir failed: $!\n";
+
+require TestDriver;
+
+cleanup();
+
+my $td = new TestDriver('flatten-annotations');
+
+my $n_tests = 0;
+
+# manual-appearances was created by hand-coding appearance streams
+# with graphics that make it easy to test matrix calculations. The
+# result of flattening the annotations was compared visually with
+# okular. Some PDF viewers don't actually display the original version
+# correctly. The pages are as follows:
+# - page 1: normal
+# - page 2: rotate 90 with /F 20 (NoRotate)
+# - page 3: non-trivial matrix
+# - page 4: non-trivial matrix, rotate
+# - page 5: rotate 180 with /F 20
+# - page 6: rotate 90, /F 20, non-trivial matrix
+# - page 7: flags: top is print, middle is screen, bottom is hidden
+# - page 8: rotate 270 with /F 20
+# - page 9: normal -- available for additional testing
+#
+# form-filled-by-acrobat was filled in using the Acrobat Reader
+# android app. One of its appearance streams is actually an image.
+#
+# need-appearances.pdf is based on field-types.pdf with manual edits
+# to turn on NeedAppearances, change /V for several fields, and add
+# the comment annotation from comment-annotation.pdf. The test output
+# includes a flattened version of the comment annotation but not of
+# the form fields. Changes:
+# - field-types.pdf has /NeedAppearances true
+# - text1: blank -> abc
+# - r1: 1 -> 2
+# - list1: blank -> five
+# - combolist1: blank -> pi
+# - drop1: blank -> elephant
+# - combodrop1: blank -> delta
+
+my @annotation_files = (
+ 'manual-appearances',
+ 'form-filled-by-acrobat',
+ 'comment-annotation',
+ 'comment-annotation-direct',
+ 'sample-form',
+ 'need-appearances',
+ 'need-appearances-more',
+ );
+$n_tests += 2 * scalar(@annotation_files);
+
+foreach my $f (@annotation_files)
+{
+ my $exp_out = {$td->STRING => "", $td->EXIT_STATUS => 0};
+ if (-f "$f-warn.out")
+ {
+ $exp_out = {$td->FILE => "$f-warn.out", $td->EXIT_STATUS => 3};
+ }
+ $td->runtest("flatten $f",
+ {$td->COMMAND =>
+ "qpdf --qdf --static-id --no-original-object-ids" .
+ " --flatten-annotations=all $f.pdf a.pdf"},
+ $exp_out,
+ $td->NORMALIZE_NEWLINES);
+ $td->runtest("check output",
+ {$td->FILE => "a.pdf"},
+ {$td->FILE => "$f-out.pdf"});
+}
+
+$n_tests += 4;
+foreach my $f (qw(screen print))
+{
+ $td->runtest("flatten for $f",
+ {$td->COMMAND =>
+ "qpdf --qdf --static-id --no-original-object-ids" .
+ " --flatten-annotations=$f manual-appearances.pdf a.pdf"},
+ {$td->STRING => "", $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
+ $td->runtest("check output",
+ {$td->FILE => "a.pdf"},
+ {$td->FILE => "manual-appearances-$f-out.pdf"});
+}
+
+cleanup();
+$td->report($n_tests);