Diffstat (limited to 'noncore/unsupported/qpdf/xpdf/PDFDoc.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/qpdf/xpdf/PDFDoc.h | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/noncore/unsupported/qpdf/xpdf/PDFDoc.h b/noncore/unsupported/qpdf/xpdf/PDFDoc.h new file mode 100644 index 0000000..592095e --- a/dev/null +++ b/noncore/unsupported/qpdf/xpdf/PDFDoc.h | |||
@@ -0,0 +1,142 @@ | |||
1 | //======================================================================== | ||
2 | // | ||
3 | // PDFDoc.h | ||
4 | // | ||
5 | // Copyright 1996 Derek B. Noonburg | ||
6 | // | ||
7 | //======================================================================== | ||
8 | |||
9 | #ifndef PDFDOC_H | ||
10 | #define PDFDOC_H | ||
11 | |||
12 | #ifdef __GNUC__ | ||
13 | #pragma interface | ||
14 | #endif | ||
15 | |||
16 | #include <stdio.h> | ||
17 | #include "XRef.h" | ||
18 | #include "Link.h" | ||
19 | #include "Catalog.h" | ||
20 | #include "Page.h" | ||
21 | |||
22 | class GString; | ||
23 | class BaseStream; | ||
24 | class OutputDev; | ||
25 | class Links; | ||
26 | class LinkAction; | ||
27 | class LinkDest; | ||
28 | |||
29 | //------------------------------------------------------------------------ | ||
30 | // PDFDoc | ||
31 | //------------------------------------------------------------------------ | ||
32 | |||
33 | class PDFDoc { | ||
34 | public: | ||
35 | |||
36 | PDFDoc(GString *fileNameA, GString *ownerPassword = NULL, | ||
37 | GString *userPassword = NULL, GBool printCommandsA = gFalse); | ||
38 | PDFDoc(BaseStream *strA, GString *ownerPassword = NULL, | ||
39 | GString *userPassword = NULL, GBool printCommandsA = gFalse); | ||
40 | ~PDFDoc(); | ||
41 | |||
42 | // Was PDF document successfully opened? | ||
43 | GBool isOk() { return ok; } | ||
44 | |||
45 | // Get file name. | ||
46 | GString *getFileName() { return fileName; } | ||
47 | |||
48 | // Get the xref table. | ||
49 | XRef *getXRef() { return xref; } | ||
50 | |||
51 | // Get catalog. | ||
52 | Catalog *getCatalog() { return catalog; } | ||
53 | |||
54 | // Get base stream. | ||
55 | BaseStream *getBaseStream() { return str; } | ||
56 | |||
57 | // Get page parameters. | ||
58 | fouble getPageWidth(int page) | ||
59 | { return catalog->getPage(page)->getWidth(); } | ||
60 | fouble getPageHeight(int page) | ||
61 | { return catalog->getPage(page)->getHeight(); } | ||
62 | int getPageRotate(int page) | ||
63 | { return catalog->getPage(page)->getRotate(); } | ||
64 | |||
65 | // Get number of pages. | ||
66 | int getNumPages() { return catalog->getNumPages(); } | ||
67 | |||
68 | // Return the contents of the metadata stream, or NULL if there is | ||
69 | // no metadata. | ||
70 | GString *readMetadata() { return catalog->readMetadata(); } | ||
71 | |||
72 | // Return the structure tree root object. | ||
73 | Object *getStructTreeRoot() { return catalog->getStructTreeRoot(); } | ||
74 | |||
75 | // Display a page. | ||
76 | void displayPage(OutputDev *out, int page, fouble zoom, | ||
77 | int rotate, GBool doLinks); | ||
78 | |||
79 | // Display a range of pages. | ||
80 | void displayPages(OutputDev *out, int firstPage, int lastPage, | ||
81 | int zoom, int rotate, GBool doLinks); | ||
82 | |||
83 | // Find a page, given its object ID. Returns page number, or 0 if | ||
84 | // not found. | ||
85 | int findPage(int num, int gen) { return catalog->findPage(num, gen); } | ||
86 | |||
87 | // If point <x>,<y> is in a link, return the associated action; | ||
88 | // else return NULL. | ||
89 | LinkAction *findLink(fouble x, fouble y) { return links->find(x, y); } | ||
90 | |||
91 | // Return true if <x>,<y> is in a link. | ||
92 | GBool onLink(fouble x, fouble y) { return links->onLink(x, y); } | ||
93 | |||
94 | // Find a named destination. Returns the link destination, or | ||
95 | // NULL if <name> is not a destination. | ||
96 | LinkDest *findDest(GString *name) | ||
97 | { return catalog->findDest(name); } | ||
98 | |||
99 | // Is the file encrypted? | ||
100 | GBool isEncrypted() { return xref->isEncrypted(); } | ||
101 | |||
102 | // Check various permissions. | ||
103 | GBool okToPrint(GBool ignoreOwnerPW = gFalse) | ||
104 | { return xref->okToPrint(ignoreOwnerPW); } | ||
105 | GBool okToChange(GBool ignoreOwnerPW = gFalse) | ||
106 | { return xref->okToChange(ignoreOwnerPW); } | ||
107 | GBool okToCopy(GBool ignoreOwnerPW = gFalse) | ||
108 | { return xref->okToCopy(ignoreOwnerPW); } | ||
109 | GBool okToAddNotes(GBool ignoreOwnerPW = gFalse) | ||
110 | { return xref->okToAddNotes(ignoreOwnerPW); } | ||
111 | |||
112 | // Is this document linearized? | ||
113 | GBool isLinearized(); | ||
114 | |||
115 | // Return the document's Info dictionary (if any). | ||
116 | Object *getDocInfo(Object *obj) { return xref->getDocInfo(obj); } | ||
117 | |||
118 | // Return the PDF version specified by the file. | ||
119 | fouble getPDFVersion() { return pdfVersion; } | ||
120 | |||
121 | // Save this file with another name. | ||
122 | GBool saveAs(GString *name); | ||
123 | |||
124 | private: | ||
125 | |||
126 | GBool setup(GString *ownerPassword, GString *userPassword); | ||
127 | void checkHeader(); | ||
128 | void getLinks(Page *page); | ||
129 | |||
130 | GString *fileName; | ||
131 | FILE *file; | ||
132 | BaseStream *str; | ||
133 | fouble pdfVersion; | ||
134 | XRef *xref; | ||
135 | Catalog *catalog; | ||
136 | Links *links; | ||
137 | GBool printCommands; | ||
138 | |||
139 | GBool ok; | ||
140 | }; | ||
141 | |||
142 | #endif | ||