blob: d01ac04612ec5024ea13c606d6a940b5f308388e (
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
|
#include <qpdf/QPDF.hh>
#include <qpdf/QPDFObjGen.hh>
#include <qpdf/QPDFXRefEntry.hh>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
int
main(int argc, char* argv[])
{
if (argc != 2) {
std::cerr << "usage: test_xref INPUT.pdf" << std::endl;
std::exit(2);
}
try {
QPDF qpdf;
qpdf.processFile(argv[1]);
for (auto const& iter: qpdf.getXRefTable()) {
std::cout << iter.first.getObj() << "/" << iter.first.getGen()
<< ", ";
switch (iter.second.getType()) {
case 0:
std::cout << "free entry" << std::endl;
break;
case 1:
std::cout << "uncompressed, offset = "
<< iter.second.getOffset() << " (0x" << std::hex
<< iter.second.getOffset() << std::dec << ")"
<< std::endl;
break;
case 2:
std::cout << "compressed, stream number = "
<< iter.second.getObjStreamNumber()
<< ", stream index = "
<< iter.second.getObjStreamIndex() << std::endl;
break;
default:
std::cerr << "unknown" << std::endl;
std::exit(2);
}
}
} catch (std::exception& e) {
std::cerr << e.what() << std::endl;
std::exit(2);
}
return 0;
}
|