Commit 8a32515a62960af10abfb863157a4c67ea3b506f
1 parent
272fb9de
Add warnings for some additional page tree repair
Showing
8 changed files
with
34 additions
and
7 deletions
libqpdf/QPDF_pages.cc
| ... | ... | @@ -110,12 +110,19 @@ QPDF::getAllPagesInternal( |
| 110 | 110 | QPDFObjectHandle kid = kids.getArrayItem(i); |
| 111 | 111 | if (!kid.isIndirect()) { |
| 112 | 112 | QTC::TC("qpdf", "QPDF handle direct page object"); |
| 113 | + cur_node.warnIfPossible( | |
| 114 | + "kid " + QUtil::int_to_string(i) + | |
| 115 | + " (from 0) is direct; converting to indirect"); | |
| 113 | 116 | kid = makeIndirectObject(kid); |
| 114 | 117 | kids.setArrayItem(i, kid); |
| 115 | 118 | } else if (seen.count(kid.getObjGen())) { |
| 116 | 119 | // Make a copy of the page. This does the same as |
| 117 | 120 | // shallowCopyPage in QPDFPageObjectHelper. |
| 118 | 121 | QTC::TC("qpdf", "QPDF resolve duplicated page object"); |
| 122 | + cur_node.warnIfPossible( | |
| 123 | + "kid " + QUtil::int_to_string(i) + | |
| 124 | + " (from 0) appears more than once in the pages tree;" | |
| 125 | + " creating a new page object as a copy"); | |
| 119 | 126 | kid = makeIndirectObject(QPDFObjectHandle(kid).shallowCopy()); |
| 120 | 127 | kids.setArrayItem(i, kid); |
| 121 | 128 | } | ... | ... |
qpdf/qtest/pages-tree.test
| ... | ... | @@ -14,13 +14,14 @@ cleanup(); |
| 14 | 14 | |
| 15 | 15 | my $td = new TestDriver('pages-tree'); |
| 16 | 16 | |
| 17 | -my $n_tests = 11; | |
| 17 | +my $n_tests = 13; | |
| 18 | 18 | |
| 19 | 19 | $td->runtest("linearize duplicated pages", |
| 20 | 20 | {$td->COMMAND => |
| 21 | 21 | "qpdf --static-id --linearize" . |
| 22 | 22 | " page_api_2.pdf a.pdf"}, |
| 23 | - {$td->STRING => "", $td->EXIT_STATUS => 0}, | |
| 23 | + {$td->FILE => "duplicate-page-warning.out", | |
| 24 | + $td->EXIT_STATUS => 3}, | |
| 24 | 25 | $td->NORMALIZE_NEWLINES); |
| 25 | 26 | $td->runtest("compare files", |
| 26 | 27 | {$td->FILE => "a.pdf"}, |
| ... | ... | @@ -29,7 +30,8 @@ $td->runtest("extract duplicated pages", |
| 29 | 30 | {$td->COMMAND => |
| 30 | 31 | "qpdf --static-id page_api_2.pdf" . |
| 31 | 32 | " --pages . -- a.pdf"}, |
| 32 | - {$td->STRING => "", $td->EXIT_STATUS => 0}, | |
| 33 | + {$td->FILE => "duplicate-page-warning.out", | |
| 34 | + $td->EXIT_STATUS => 3}, | |
| 33 | 35 | $td->NORMALIZE_NEWLINES); |
| 34 | 36 | $td->runtest("compare files", |
| 35 | 37 | {$td->FILE => "a.pdf"}, |
| ... | ... | @@ -37,7 +39,7 @@ $td->runtest("compare files", |
| 37 | 39 | $td->runtest("direct pages", |
| 38 | 40 | {$td->COMMAND => |
| 39 | 41 | "qpdf --static-id direct-pages.pdf --pages . -- a.pdf"}, |
| 40 | - {$td->STRING => "", $td->EXIT_STATUS => 0}, | |
| 42 | + {$td->FILE => "direct-page-warning.out", $td->EXIT_STATUS => 3}, | |
| 41 | 43 | $td->NORMALIZE_NEWLINES); |
| 42 | 44 | $td->runtest("check output", |
| 43 | 45 | {$td->FILE => "a.pdf"}, |
| ... | ... | @@ -45,7 +47,7 @@ $td->runtest("check output", |
| 45 | 47 | $td->runtest("show direct pages", |
| 46 | 48 | {$td->COMMAND => |
| 47 | 49 | "qpdf --show-pages direct-pages.pdf"}, |
| 48 | - {$td->FILE => "direct-pages.out", $td->EXIT_STATUS => 0}, | |
| 50 | + {$td->FILE => "direct-pages.out", $td->EXIT_STATUS => 3}, | |
| 49 | 51 | $td->NORMALIZE_NEWLINES); |
| 50 | 52 | |
| 51 | 53 | # Json mode for direct and duplicated pages illustrates that the |
| ... | ... | @@ -62,8 +64,12 @@ foreach my $f (qw(page_api_2 direct-pages)) |
| 62 | 64 | $td->runtest("json for $f (with pages)", |
| 63 | 65 | {$td->COMMAND => |
| 64 | 66 | "qpdf --json=latest $f.pdf" . |
| 65 | - " --json-key=objects --json-key=pages"}, | |
| 66 | - {$td->FILE => "$f-json-pages.out", $td->EXIT_STATUS => 0}, | |
| 67 | + " --json-key=objects --json-key=pages 2>warn.tmpout"}, | |
| 68 | + {$td->FILE => "$f-json-pages.out", $td->EXIT_STATUS => 3}, | |
| 69 | + $td->NORMALIZE_NEWLINES); | |
| 70 | + $td->runtest("check page warnings", | |
| 71 | + {$td->FILE => "warn.tmpout"}, | |
| 72 | + {$td->FILE => "$f-json-warning.out"}, | |
| 67 | 73 | $td->NORMALIZE_NEWLINES); |
| 68 | 74 | } |
| 69 | 75 | ... | ... |
qpdf/qtest/qpdf/direct-page-warning.out
0 → 100644
qpdf/qtest/qpdf/direct-pages-json-warning.out
0 → 100644
qpdf/qtest/qpdf/direct-pages.out
| 1 | +WARNING: direct-pages.pdf, object 2 0 at offset 143: kid 0 (from 0) is direct; converting to indirect | |
| 2 | +WARNING: direct-pages.pdf, object 2 0 at offset 143: kid 1 (from 0) is direct; converting to indirect | |
| 1 | 3 | page 1: 7 0 R |
| 2 | 4 | content: |
| 3 | 5 | 3 0 R |
| 4 | 6 | page 2: 8 0 R |
| 5 | 7 | content: |
| 6 | 8 | 3 0 R |
| 9 | +qpdf: operation succeeded with warnings | ... | ... |
qpdf/qtest/qpdf/duplicate-page-warning.out
0 → 100644
qpdf/qtest/qpdf/page_api_2-json-warning.out
0 → 100644
qpdf/qtest/qpdf/page_api_2.out