diff --git a/qpdf/qtest/deterministic-id.test b/qpdf/qtest/deterministic-id.test
index 9aeb7f38..a975806a 100644
--- a/qpdf/qtest/deterministic-id.test
+++ b/qpdf/qtest/deterministic-id.test
@@ -2,6 +2,7 @@
require 5.008;
use warnings;
use strict;
+use File::Copy;
unshift(@INC, '.');
require qpdf_test_helpers;
@@ -14,23 +15,41 @@ cleanup();
my $td = new TestDriver('deterministic-id');
-my $n_tests = 11;
+my $n_tests = 19;
+
+# Do not use qpdf-test-compare in this test suite since it ignores
+# /ID[1].
foreach my $d ('nn', 'ny', 'yn', 'yy')
{
my $linearize = ($d =~ m/^y/);
my $ostream = ($d =~ m/y$/);
- $td->runtest("deterministic ID: linearize/ostream=$d",
- {$td->COMMAND =>
- "qpdf -deterministic-id" .
- ($linearize ? " -linearize" : "") .
- " -object-streams=" . ($ostream ? "generate" : "disable") .
- " deterministic-id-in.pdf a.pdf"},
- {$td->STRING => "",
- $td->EXIT_STATUS => 0});
+ # The deterministic ID is a function of all the data in the file.
+ # As such, it is affected by which zlib implementation is in use.
+ # The important thing is that the ID is the same if a file is
+ # generated the same way more than once, so rather than comparing
+ # the output file to a known output, compare subsequent outputs
+ # with each other.
+ foreach my $out ('a.pdf', 'b.pdf')
+ {
+ $td->runtest("deterministic ID: linearize/ostream=$d",
+ {$td->COMMAND =>
+ "qpdf -deterministic-id" .
+ ($linearize ? " -linearize" : "") .
+ " -object-streams=" . ($ostream ? "generate" : "disable") .
+ " deterministic-id-in.pdf $out"},
+ {$td->STRING => "",
+ $td->EXIT_STATUS => 0});
+ }
$td->runtest("compare files",
{$td->FILE => "a.pdf"},
- {$td->FILE => "deterministic-id-$d.pdf"});
+ {$td->FILE => "b.pdf"});
+ check_id('a.pdf');
+ if ($d eq 'nn')
+ {
+ # Save for the C API test
+ copy("a.pdf", 'c.pdf');
+ }
}
$td->runtest("deterministic ID with encryption",
@@ -49,7 +68,27 @@ $td->runtest("deterministic ID (C API)",
$td->NORMALIZE_NEWLINES);
$td->runtest("compare files",
{$td->FILE => "a.pdf"},
- {$td->FILE => "deterministic-id-nn.pdf"});
+ {$td->FILE => "c.pdf"});
cleanup();
$td->report($n_tests);
+
+sub check_id
+{
+ my $f = shift;
+ chomp(my $id = `qpdf --show-object=trailer $f`);
+ if ($id =~ m,.*/ID \[ <(9b1c69409fc9a5f50e44b9588e3e60f8)> <(.{32})>,)
+ {
+ my $id0 = $1;
+ my $id1 = $2;
+ $td->runtest("ID fields differ",
+ {$td->STRING => $id0 ne $id1 ? "YES\n" : "$id0 $id1\n"},
+ {$td->STRING => "YES\n"});
+ }
+ else
+ {
+ $td->runtest("checked ID",
+ {$td->STRING => "YES\n"},
+ {$td->STRING => "$id\n"});
+ }
+}
diff --git a/qpdf/qtest/qpdf/deterministic-id-nn.pdf b/qpdf/qtest/qpdf/deterministic-id-nn.pdf
deleted file mode 100644
index 0b71a444..00000000
--- a/qpdf/qtest/qpdf/deterministic-id-nn.pdf
+++ /dev/null
@@ -1,1852 +0,0 @@
-%PDF-1.4
-%
-1 0 obj
-<< /Lang (en) /Metadata 3 0 R /PageLabels 4 0 R /Pages 5 0 R /Type /Catalog >>
-endobj
-2 0 obj
-<< /CreationDate (D:20150524172830-04'00') /Creator (Apache FOP Version 1.1) /Producer (Apache FOP Version 1.1) >>
-endobj
-3 0 obj
-<< /Subtype /XML /Type /Metadata /Length 858 >>
-stream
-
-
-
-application/pdf
-en
-2015-05-24T17:28:30-04:00
-
-
-Apache FOP Version 1.1
-1.4
-
-
-Apache FOP Version 1.1
-2015-05-24T17:28:30-04:00
-2015-05-24T17:28:30-04:00
-
-
-
-endstream
-endobj
-4 0 obj
-<< /Nums [ 0 << /P (i) >> 1 << /P (ii) >> 2 << /P (iii) >> 3 << /P (iv) >> 4 << /P (1) >> 5 << /P (2) >> 6 << /P (3) >> 7 << /P (4) >> 8 << /P (5) >> 9 << /P (6) >> 10 << /P (7) >> 11 << /P (8) >> 12 << /P (9) >> 13 << /P (10) >> 14 << /P (11) >> 15 << /P (12) >> 16 << /P (13) >> 17 << /P (14) >> 18 << /P (15) >> 19 << /P (16) >> 20 << /P (17) >> 21 << /P (18) >> 22 << /P (19) >> 23 << /P (20) >> 24 << /P (21) >> 25 << /P (22) >> 26 << /P (23) >> 27 << /P (24) >> 28 << /P (25) >> 29 << /P (26) >> 30 << /P (27) >> 31 << /P (28) >> 32 << /P (29) >> 33 << /P (30) >> 34 << /P (31) >> 35 << /P (32) >> 36 << /P (33) >> 37 << /P (34) >> 38 << /P (35) >> 39 << /P (36) >> 40 << /P (37) >> 41 << /P (38) >> 42 << /P (39) >> ] >>
-endobj
-5 0 obj
-<< /Count 43 /Kids [ 6 0 R 7 0 R 8 0 R 9 0 R 10 0 R 11 0 R 12 0 R 13 0 R 14 0 R 15 0 R 16 0 R 17 0 R 18 0 R 19 0 R 20 0 R 21 0 R 22 0 R 23 0 R 24 0 R 25 0 R 26 0 R 27 0 R 28 0 R 29 0 R 30 0 R 31 0 R 32 0 R 33 0 R 34 0 R 35 0 R 36 0 R 37 0 R 38 0 R 39 0 R 40 0 R 41 0 R 42 0 R 43 0 R 44 0 R 45 0 R 46 0 R 47 0 R 48 0 R ] /Type /Pages >>
-endobj
-6 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 49 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-7 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 51 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-8 0 obj
-<< /Annots 52 0 R /BleedBox [ 0 0 612 792 ] /Contents 53 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-9 0 obj
-<< /Annots 54 0 R /BleedBox [ 0 0 612 792 ] /Contents 55 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-10 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 56 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-11 0 obj
-<< /Annots 57 0 R /BleedBox [ 0 0 612 792 ] /Contents 58 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-12 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 59 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-13 0 obj
-<< /Annots 60 0 R /BleedBox [ 0 0 612 792 ] /Contents 61 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-14 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 62 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-15 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 63 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-16 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 64 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-17 0 obj
-<< /Annots 65 0 R /BleedBox [ 0 0 612 792 ] /Contents 66 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-18 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 67 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-19 0 obj
-<< /Annots 68 0 R /BleedBox [ 0 0 612 792 ] /Contents 69 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-20 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 70 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-21 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 71 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-22 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 72 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-23 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 73 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-24 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 74 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-25 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 75 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-26 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 76 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-27 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 77 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-28 0 obj
-<< /Annots 78 0 R /BleedBox [ 0 0 612 792 ] /Contents 79 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-29 0 obj
-<< /Annots 80 0 R /BleedBox [ 0 0 612 792 ] /Contents 81 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-30 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 82 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-31 0 obj
-<< /Annots 83 0 R /BleedBox [ 0 0 612 792 ] /Contents 84 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-32 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 85 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-33 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 86 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-34 0 obj
-<< /Annots 87 0 R /BleedBox [ 0 0 612 792 ] /Contents 88 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-35 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 89 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-36 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 90 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-37 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 91 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-38 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 92 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-39 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 93 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-40 0 obj
-<< /Annots 94 0 R /BleedBox [ 0 0 612 792 ] /Contents 95 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-41 0 obj
-<< /Annots 96 0 R /BleedBox [ 0 0 612 792 ] /Contents 97 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-42 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 98 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-43 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 99 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-44 0 obj
-<< /Annots 100 0 R /BleedBox [ 0 0 612 792 ] /Contents 101 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-45 0 obj
-<< /Annots 102 0 R /BleedBox [ 0 0 612 792 ] /Contents 103 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-46 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 104 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-47 0 obj
-<< /BleedBox [ 0 0 612 792 ] /Contents 105 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-48 0 obj
-<< /Annots 106 0 R /BleedBox [ 0 0 612 792 ] /Contents 107 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources 50 0 R /TrimBox [ 0 0 612 792 ] /Type /Page >>
-endobj
-49 0 obj
-<< /Filter /FlateDecode /Length 225 >>
-stream
-xuMKA+rT1̵
-Pebk{ofWh&I3;c+ ~5**Mck$?r_"s8`9@> /Font << /F10 109 0 R /F11 110 0 R /F12 111 0 R /F3 112 0 R /F4 113 0 R /F5 114 0 R /F6 115 0 R /F7 116 0 R /F9 117 0 R >> /ProcSet [ /PDF /ImageB /ImageC /Text ] >>
-endobj
-51 0 obj
-<< /Filter /FlateDecode /Length 336 >>
-stream
-xSMO@ﯘ&vjƶHUJ+Mf2ͼHB{L%x)IJ) CƂ$(
pcHIV&r·v9
}hEGBg0n#7Q/C#AAyچF 9p3c=q,s0Dk')Zu)`t2ݴ_Ti-J0RIa|
uP $.o@a8iFB=-|2|Wu+hq#-2Qx7kLF5]~..@3&