aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qtest/custom-filter.test
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2020-12-26 17:13:00 +0100
committerJay Berkenbilt <ejb@ql.org>2020-12-28 19:03:04 +0100
commitd4d7630cf544dc295202382026658b55bf49f76b (patch)
tree2a5796a99c99f0ee3d27db7f412923e697dd8781 /examples/qtest/custom-filter.test
parentac042d16cfe6efd1ff3295e1507558a2f87ec73f (diff)
downloadqpdf-d4d7630cf544dc295202382026658b55bf49f76b.tar.zst
Add pdf-custom-filter example
Diffstat (limited to 'examples/qtest/custom-filter.test')
-rw-r--r--examples/qtest/custom-filter.test47
1 files changed, 47 insertions, 0 deletions
diff --git a/examples/qtest/custom-filter.test b/examples/qtest/custom-filter.test
new file mode 100644
index 00000000..e674ea66
--- /dev/null
+++ b/examples/qtest/custom-filter.test
@@ -0,0 +1,47 @@
+#!/usr/bin/env perl
+require 5.008;
+use warnings;
+use strict;
+
+chdir("custom-filter") or die "chdir testdir failed: $!\n";
+
+require TestDriver;
+
+cleanup();
+
+my $td = new TestDriver('custom-filter');
+
+# The file input.pdf contains two streams, whose contents appear
+# uncompressed with explanatory text. They are marked with the keys
+# that pdf-custom-filter uses to decide 1) to re-encode using the
+# fictitious /XORDecode filter, and 2) whether to protect the stream
+# to prevent decoding using the custom filter even when decoding
+# specialized filters is requested.
+
+$td->runtest("custom filter, decode generalized",
+ {$td->COMMAND => "pdf-custom-filter input.pdf a.pdf"},
+ {$td->STRING => "pdf-custom-filter: new file written to a.pdf\n",
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
+$td->runtest("check output",
+ {$td->FILE => "a.pdf"},
+ {$td->FILE => "generalized.pdf"});
+
+$td->runtest("custom filter, decode specialized",
+ {$td->COMMAND =>
+ "pdf-custom-filter --decode-specialized input.pdf a.pdf"},
+ {$td->STRING => "pdf-custom-filter: new file written to a.pdf\n",
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
+$td->runtest("check output",
+ {$td->FILE => "a.pdf"},
+ {$td->FILE => "specialized.pdf"});
+
+cleanup();
+
+$td->report(4);
+
+sub cleanup
+{
+ unlink "a.pdf";
+}