From 08379321645133ba74dad4ce130055c087130bab Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 5 Apr 2020 17:18:46 -0400 Subject: Update documentation and test suite to lock in hard page copy Issue #399 mentioned a use case for which qpdf has support, but the fact that it is supported was not documented or in the test suite, making it vulerable to accidental breakage. --- manual/qpdf-manual.xml | 11 ++++++++++- qpdf/qtest/qpdf.test | 15 ++++++++++++++- qpdf/qtest/qpdf/deep-duplicate-pages.pdf | Bin 0 -> 1287 bytes 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 qpdf/qtest/qpdf/deep-duplicate-pages.pdf diff --git a/manual/qpdf-manual.xml b/manual/qpdf-manual.xml index a2dff114..c875baa2 100644 --- a/manual/qpdf-manual.xml +++ b/manual/qpdf-manual.xml @@ -1588,7 +1588,16 @@ outfile.pdf Prior to version 8.4, it was not possible to specify the same page from the same file directly more than once, and the workaround of specifying the same file in more than one way was required. - Version 8.4 removes this limitation. + Version 8.4 removes this limitation, but there is still a valid + use case. When you specify the same page from the same file more + than once, qpdf will share objects between the pages. If you are + going to do further manipulation on the file and need the two + instances of the same original page to be deep copies, then you + can specify the file in two different ways. For example + qpdf in.pdf --pages . 1 ./in.pdf 1 -- out.pdf + would create a file with two copies of the first page of the + input, and the two copies would share any objects in common. This + includes fonts, images, and anything else the page references. diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test index e012b202..788ef2dc 100644 --- a/qpdf/qtest/qpdf.test +++ b/qpdf/qtest/qpdf.test @@ -2057,7 +2057,7 @@ foreach my $f (qw(page_api_2 direct-pages)) show_ntests(); # ---------- $td->notify("--- Merging and Splitting ---"); -$n_tests += 24; +$n_tests += 26; # Select pages from the same file multiple times including selecting # twice from an encrypted file and specifying the password only the @@ -2200,6 +2200,19 @@ $td->runtest("check output", {$td->FILE => "a.pdf"}, {$td->FILE => "duplicate-pages.pdf"}); +# See https://github.com/qpdf/qpdf/issues/399 -- we don't want to +# break this, especially if we ever implement deduplication of +# identical streams. +$td->runtest("force full page duplication", + {$td->COMMAND => "qpdf --static-id minimal.pdf" . + " --pages . ./minimal.pdf -- a.pdf"}, + {$td->STRING => "", $td->EXIT_STATUS => 0}, + $td->NORMALIZE_NEWLINES); +$td->runtest("check output", + {$td->FILE => "a.pdf"}, + {$td->FILE => "deep-duplicate-pages.pdf"}); + + show_ntests(); # ---------- $td->notify("--- Collating ---"); diff --git a/qpdf/qtest/qpdf/deep-duplicate-pages.pdf b/qpdf/qtest/qpdf/deep-duplicate-pages.pdf new file mode 100644 index 00000000..2d273765 Binary files /dev/null and b/qpdf/qtest/qpdf/deep-duplicate-pages.pdf differ -- cgit v1.2.3-54-g00ecf