2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 10:58:58 +00:00

Added test code for Tobias's changes

This commit is contained in:
Jay Berkenbilt 2012-07-04 23:19:32 -04:00
parent abb53ac369
commit c227249ef1
8 changed files with 59 additions and 33 deletions

View File

@ -1,3 +1,10 @@
2012-07-04 Jay Berkenbilt <ejb@ql.org>
* Accept changes from Tobias Hoffmann: add public method
QPDF::pushInheritedAttributesToPage including warnings for
non-inherited keys that may be discarded from /Pages by
non-conformant PDF files when the /Pages tree is flattened.
2012-06-27 Jay Berkenbilt <ejb@ql.org> 2012-06-27 Jay Berkenbilt <ejb@ql.org>
* Add Pl_Concatenate pipeline for stream concatenation also * Add Pl_Concatenate pipeline for stream concatenation also

View File

@ -149,7 +149,7 @@ $td->runtest("remove page we don't have",
$td->NORMALIZE_NEWLINES); $td->NORMALIZE_NEWLINES);
# ---------- # ----------
$td->notify("--- Miscellaneous Tests ---"); $td->notify("--- Miscellaneous Tests ---");
$n_tests += 40; $n_tests += 41;
$td->runtest("qpdf version", $td->runtest("qpdf version",
{$td->COMMAND => "qpdf --version"}, {$td->COMMAND => "qpdf --version"},
@ -354,6 +354,10 @@ $td->runtest("shallow copy a stream",
{$td->COMMAND => "test_driver 21 shallow_array.pdf"}, {$td->COMMAND => "test_driver 21 shallow_array.pdf"},
{$td->FILE => "shallow_stream.out", $td->EXIT_STATUS => 2}, {$td->FILE => "shallow_stream.out", $td->EXIT_STATUS => 2},
$td->NORMALIZE_NEWLINES); $td->NORMALIZE_NEWLINES);
$td->runtest("warn for unknown key in Pages",
{$td->COMMAND => "test_driver 23 lin-special.pdf"},
{$td->FILE => "pages-warning.out", $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
show_ntests(); show_ntests();
# ---------- # ----------

View File

@ -22,13 +22,16 @@
% +---- page 5 % +---- page 5
% %
% Node (A) defines /MediaBox (direct) and /Resources (indirect) % Node (A) defines /MediaBox (direct) and /Resources (indirect)
% Node (B) overrides /MediaBox % Node (B) overrides /MediaBox and defines /Rotate
% Node (B) defines /Quack, a non-standard key, which is not inherited
% Page 1 overrides /Resources % Page 1 overrides /Resources
% Page 4 overrides /Resources % Page 4 overrides /Resources
% Page 5 overrides /MediaBox % Page 5 overrides /MediaBox and /Rotate
% %
% Page 5 provides the case of two levels of shadowing on a resource. % Page 5 provides the case of two levels of shadowing on a resource.
% %
% Node (B)'s overriding of /Rotate exercises inheriting a scalar.
%
% The /MediaBox defined in node (B) is shared between pages 3 and 4 % The /MediaBox defined in node (B) is shared between pages 3 and 4
% but not page 1. The /MediaBox defined in node (A) is shared between % but not page 1. The /MediaBox defined in node (A) is shared between
% pages 1 and 2 only. % pages 1 and 2 only.
@ -58,6 +61,7 @@ endobj
>> >>
endobj endobj
% Node (A)
3 0 obj 3 0 obj
<< <<
/Count 5 /Count 5
@ -73,7 +77,6 @@ endobj
792 792
] ]
/Resources 7 0 R /Resources 7 0 R
/Quack 16059
/Type /Pages /Type /Pages
>> >>
endobj endobj
@ -97,6 +100,7 @@ endobj
>> >>
endobj endobj
% Node (B)
6 0 obj 6 0 obj
<< <<
/Count 3 /Count 3
@ -112,6 +116,8 @@ endobj
396 396
] ]
/Parent 3 0 R /Parent 3 0 R
/Rotate 0
/Quack 16059
/Type /Pages /Type /Pages
>> >>
endobj endobj
@ -205,6 +211,7 @@ endobj
306 306
396 396
] ]
/Rotate 180
/Parent 6 0 R /Parent 6 0 R
/Type /Page /Type /Page
>> >>
@ -316,39 +323,39 @@ endobj
xref xref
0 29 0 29
0000000000 65535 f 0000000000 65535 f
0000001161 00000 n 0000001331 00000 n
0000001244 00000 n 0000001414 00000 n
0000001319 00000 n 0000001500 00000 n
0000001501 00000 n 0000001667 00000 n
0000001601 00000 n 0000001767 00000 n
0000001672 00000 n 0000001849 00000 n
0000001829 00000 n 0000002033 00000 n
0000001923 00000 n 0000002127 00000 n
0000002024 00000 n 0000002228 00000 n
0000002043 00000 n 0000002247 00000 n
0000002138 00000 n 0000002342 00000 n
0000002241 00000 n 0000002445 00000 n
0000002271 00000 n 0000002475 00000 n
0000002366 00000 n 0000002570 00000 n
0000002526 00000 n 0000002730 00000 n
0000002644 00000 n 0000002862 00000 n
0000002763 00000 n 0000002981 00000 n
0000002799 00000 n 0000003017 00000 n
0000002947 00000 n 0000003165 00000 n
0000003050 00000 n 0000003268 00000 n
0000003093 00000 n 0000003311 00000 n
0000003196 00000 n 0000003414 00000 n
0000003216 00000 n 0000003434 00000 n
0000003359 00000 n 0000003577 00000 n
0000003462 00000 n 0000003680 00000 n
0000003482 00000 n 0000003700 00000 n
0000003504 00000 n 0000003722 00000 n
0000003526 00000 n 0000003744 00000 n
trailer << trailer <<
/Root 1 0 R /Root 1 0 R
/Size 29 /Size 29
/ID [<ce9551b56c5a7e3b5b0ba6fa0d281296><a74aa55a69070b600e39f9ed1ed6c4df>] /ID [<ce9551b56c5a7e3b5b0ba6fa0d281296><a74aa55a69070b600e39f9ed1ed6c4df>]
>> >>
startxref startxref
3545 3763
%%EOF %%EOF

View File

@ -0,0 +1,2 @@
WARNING: lin-special.pdf (Pages object: object 6 0): Unknown key /Quack in /Pages object is being discarded as a result of flattening the /Pages tree
test 23 done

View File

@ -832,6 +832,12 @@ void runtest(int n, char const* filename)
pdf.removePage(page); pdf.removePage(page);
std::cout << "you can't see this" << std::endl; std::cout << "you can't see this" << std::endl;
} }
else if (n == 23)
{
// Try to remove a page we don't have
std::vector<QPDFObjectHandle> const& pages = pdf.getAllPages();
pdf.removePage(pages.back());
}
else else
{ {
throw std::runtime_error(std::string("invalid test ") + throw std::runtime_error(std::string("invalid test ") +