mirror of
https://github.com/qpdf/qpdf.git
synced 2024-05-31 01:10:51 +00:00
Add warnings for some additional page tree repair
This commit is contained in:
parent
272fb9de9d
commit
8a32515a62
|
@ -110,12 +110,19 @@ QPDF::getAllPagesInternal(
|
|||
QPDFObjectHandle kid = kids.getArrayItem(i);
|
||||
if (!kid.isIndirect()) {
|
||||
QTC::TC("qpdf", "QPDF handle direct page object");
|
||||
cur_node.warnIfPossible(
|
||||
"kid " + QUtil::int_to_string(i) +
|
||||
" (from 0) is direct; converting to indirect");
|
||||
kid = makeIndirectObject(kid);
|
||||
kids.setArrayItem(i, kid);
|
||||
} else if (seen.count(kid.getObjGen())) {
|
||||
// Make a copy of the page. This does the same as
|
||||
// shallowCopyPage in QPDFPageObjectHelper.
|
||||
QTC::TC("qpdf", "QPDF resolve duplicated page object");
|
||||
cur_node.warnIfPossible(
|
||||
"kid " + QUtil::int_to_string(i) +
|
||||
" (from 0) appears more than once in the pages tree;"
|
||||
" creating a new page object as a copy");
|
||||
kid = makeIndirectObject(QPDFObjectHandle(kid).shallowCopy());
|
||||
kids.setArrayItem(i, kid);
|
||||
}
|
||||
|
|
|
@ -14,13 +14,14 @@ cleanup();
|
|||
|
||||
my $td = new TestDriver('pages-tree');
|
||||
|
||||
my $n_tests = 11;
|
||||
my $n_tests = 13;
|
||||
|
||||
$td->runtest("linearize duplicated pages",
|
||||
{$td->COMMAND =>
|
||||
"qpdf --static-id --linearize" .
|
||||
" page_api_2.pdf a.pdf"},
|
||||
{$td->STRING => "", $td->EXIT_STATUS => 0},
|
||||
{$td->FILE => "duplicate-page-warning.out",
|
||||
$td->EXIT_STATUS => 3},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
$td->runtest("compare files",
|
||||
{$td->FILE => "a.pdf"},
|
||||
|
@ -29,7 +30,8 @@ $td->runtest("extract duplicated pages",
|
|||
{$td->COMMAND =>
|
||||
"qpdf --static-id page_api_2.pdf" .
|
||||
" --pages . -- a.pdf"},
|
||||
{$td->STRING => "", $td->EXIT_STATUS => 0},
|
||||
{$td->FILE => "duplicate-page-warning.out",
|
||||
$td->EXIT_STATUS => 3},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
$td->runtest("compare files",
|
||||
{$td->FILE => "a.pdf"},
|
||||
|
@ -37,7 +39,7 @@ $td->runtest("compare files",
|
|||
$td->runtest("direct pages",
|
||||
{$td->COMMAND =>
|
||||
"qpdf --static-id direct-pages.pdf --pages . -- a.pdf"},
|
||||
{$td->STRING => "", $td->EXIT_STATUS => 0},
|
||||
{$td->FILE => "direct-page-warning.out", $td->EXIT_STATUS => 3},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
$td->runtest("check output",
|
||||
{$td->FILE => "a.pdf"},
|
||||
|
@ -45,7 +47,7 @@ $td->runtest("check output",
|
|||
$td->runtest("show direct pages",
|
||||
{$td->COMMAND =>
|
||||
"qpdf --show-pages direct-pages.pdf"},
|
||||
{$td->FILE => "direct-pages.out", $td->EXIT_STATUS => 0},
|
||||
{$td->FILE => "direct-pages.out", $td->EXIT_STATUS => 3},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
|
||||
# Json mode for direct and duplicated pages illustrates that the
|
||||
|
@ -62,8 +64,12 @@ foreach my $f (qw(page_api_2 direct-pages))
|
|||
$td->runtest("json for $f (with pages)",
|
||||
{$td->COMMAND =>
|
||||
"qpdf --json=latest $f.pdf" .
|
||||
" --json-key=objects --json-key=pages"},
|
||||
{$td->FILE => "$f-json-pages.out", $td->EXIT_STATUS => 0},
|
||||
" --json-key=objects --json-key=pages 2>warn.tmpout"},
|
||||
{$td->FILE => "$f-json-pages.out", $td->EXIT_STATUS => 3},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
$td->runtest("check page warnings",
|
||||
{$td->FILE => "warn.tmpout"},
|
||||
{$td->FILE => "$f-json-warning.out"},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
}
|
||||
|
||||
|
|
3
qpdf/qtest/qpdf/direct-page-warning.out
Normal file
3
qpdf/qtest/qpdf/direct-page-warning.out
Normal file
|
@ -0,0 +1,3 @@
|
|||
WARNING: direct-pages.pdf, object 2 0 at offset 143: kid 0 (from 0) is direct; converting to indirect
|
||||
WARNING: direct-pages.pdf, object 2 0 at offset 143: kid 1 (from 0) is direct; converting to indirect
|
||||
qpdf: operation succeeded with warnings; resulting file may have some problems
|
3
qpdf/qtest/qpdf/direct-pages-json-warning.out
Normal file
3
qpdf/qtest/qpdf/direct-pages-json-warning.out
Normal file
|
@ -0,0 +1,3 @@
|
|||
WARNING: direct-pages.pdf, object 2 0 at offset 143: kid 0 (from 0) is direct; converting to indirect
|
||||
WARNING: direct-pages.pdf, object 2 0 at offset 143: kid 1 (from 0) is direct; converting to indirect
|
||||
qpdf: operation succeeded with warnings
|
|
@ -1,6 +1,9 @@
|
|||
WARNING: direct-pages.pdf, object 2 0 at offset 143: kid 0 (from 0) is direct; converting to indirect
|
||||
WARNING: direct-pages.pdf, object 2 0 at offset 143: kid 1 (from 0) is direct; converting to indirect
|
||||
page 1: 7 0 R
|
||||
content:
|
||||
3 0 R
|
||||
page 2: 8 0 R
|
||||
content:
|
||||
3 0 R
|
||||
qpdf: operation succeeded with warnings
|
||||
|
|
2
qpdf/qtest/qpdf/duplicate-page-warning.out
Normal file
2
qpdf/qtest/qpdf/duplicate-page-warning.out
Normal file
|
@ -0,0 +1,2 @@
|
|||
WARNING: page_api_2.pdf, object 3 0 at offset 175: kid 1 (from 0) appears more than once in the pages tree; creating a new page object as a copy
|
||||
qpdf: operation succeeded with warnings; resulting file may have some problems
|
2
qpdf/qtest/qpdf/page_api_2-json-warning.out
Normal file
2
qpdf/qtest/qpdf/page_api_2-json-warning.out
Normal file
|
@ -0,0 +1,2 @@
|
|||
WARNING: page_api_2.pdf, object 3 0 at offset 175: kid 1 (from 0) appears more than once in the pages tree; creating a new page object as a copy
|
||||
qpdf: operation succeeded with warnings
|
|
@ -1 +1,2 @@
|
|||
WARNING: page_api_2.pdf, object 3 0 at offset 175: kid 1 (from 0) appears more than once in the pages tree; creating a new page object as a copy
|
||||
test 17 done
|
||||
|
|
Loading…
Reference in New Issue
Block a user