aboutsummaryrefslogtreecommitdiffstats
path: root/qpdf/qtest/extraction.test
blob: 076244b72a6f4c16f62a72b6f5575b35548f2a29 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env perl
require 5.008;
use warnings;
use strict;

unshift(@INC, '.');
require qpdf_test_helpers;

chdir("qpdf") or die "chdir testdir failed: $!\n";

require TestDriver;

cleanup();

my $td = new TestDriver('extraction');

my $n_tests = 13;

$td->runtest("show xref",
             {$td->COMMAND => "qpdf encrypted-with-images.pdf" .
                  " --show-xref"},
             {$td->FILE => "show-xref.out",
              $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);

$td->runtest("show pages",
             {$td->COMMAND => "qpdf encrypted-with-images.pdf" .
                  " --show-pages"},
             {$td->FILE => "show-pages.out",
              $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);

$td->runtest("show-pages-images",
             {$td->COMMAND => "qpdf encrypted-with-images.pdf" .
                  " --show-pages --with-images"},
             {$td->FILE => "show-pages-images.out",
              $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);

$td->runtest("show-pages-images",
             {$td->COMMAND => "qpdf shared-images.pdf" .
                  " --show-pages --with-images"},
             {$td->FILE => "shared-images-show.out",
              $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);

$td->runtest("show-page-1",
             {$td->COMMAND => "qpdf encrypted-with-images.pdf" .
                  " --show-object=5,0"},
             {$td->FILE => "show-page-1.out",
              $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);

$td->runtest("show-page-1-content-raw",
             {$td->COMMAND => "qpdf encrypted-with-images.pdf" .
                  " --show-object=7 --raw-stream-data"},
             {$td->FILE => "show-page-1-content-raw.out",
              $td->EXIT_STATUS => 0});

$td->runtest("show-page-1-content-filtered",
             {$td->COMMAND => "qpdf encrypted-with-images.pdf" .
                  " --show-object=7 --filtered-stream-data"},
             {$td->FILE => "show-page-1-content-filtered.out",
              $td->EXIT_STATUS => 0});

$td->runtest("show-page-1-content-normalized",
             {$td->COMMAND => "qpdf encrypted-with-images.pdf" .
                  " --show-object=7,0 --filtered-stream-data --normalize-content=y"},
             {$td->FILE => "show-page-1-content-normalized.out",
              $td->EXIT_STATUS => 0});

$td->runtest("show-page-1-image",
             {$td->COMMAND => "qpdf encrypted-with-images.pdf" .
                  " --show-object=8 --raw-stream-data"},
             {$td->FILE => "show-page-1-image.out",
              $td->EXIT_STATUS => 0});

$td->runtest("unfilterable stream data",
             {$td->COMMAND => "qpdf unfilterable.pdf" .
                  " --show-object=4 --filtered-stream-data"},
             {$td->FILE => "show-unfilterable.out",
              $td->EXIT_STATUS => 2},
             $td->NORMALIZE_NEWLINES);

$td->runtest("show-xref-by-id",
             {$td->COMMAND => "qpdf encrypted-with-images.pdf" .
                  " --show-object=12"},
             {$td->FILE => "show-xref-by-id.out",
              $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);

$td->runtest("show-xref-by-id-filtered",
             {$td->COMMAND => "qpdf encrypted-with-images.pdf" .
                  " --show-object=12 --filtered-stream-data"},
             {$td->FILE => "show-xref-by-id-filtered.out",
              $td->EXIT_STATUS => 0});

$td->runtest("show trailer",
             {$td->COMMAND => "qpdf minimal.pdf --show-object=trailer"},
             {$td->FILE => "show-trailer.out",
              $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);

cleanup();
$td->report($n_tests);