]> www.fi.muni.cz Git - evince.git/blob - pdf/xpdf/PDFDoc.h
add GnomePrintJob to EvPrintJob constructor arguments.
[evince.git] / pdf / xpdf / PDFDoc.h
1 //========================================================================
2 //
3 // PDFDoc.h
4 //
5 // Copyright 1996-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
8
9 #ifndef PDFDOC_H
10 #define PDFDOC_H
11
12 #include <aconf.h>
13
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
17
18 #include <stdio.h>
19 #include "XRef.h"
20 #include "Link.h"
21 #include "Catalog.h"
22 #include "Page.h"
23 #include "Annot.h"
24
25 class GString;
26 class BaseStream;
27 class OutputDev;
28 class Links;
29 class LinkAction;
30 class LinkDest;
31 class Outline;
32
33 //------------------------------------------------------------------------
34 // PDFDoc
35 //------------------------------------------------------------------------
36
37 class PDFDoc {
38 public:
39
40   PDFDoc(GString *fileNameA, GString *ownerPassword = NULL,
41          GString *userPassword = NULL);
42   PDFDoc(BaseStream *strA, GString *ownerPassword = NULL,
43          GString *userPassword = NULL);
44   ~PDFDoc();
45
46   // Was PDF document successfully opened?
47   GBool isOk() { return ok; }
48
49   // Get the error code (if isOk() returns false).
50   int getErrorCode() { return errCode; }
51
52   // Get file name.
53   GString *getFileName() { return fileName; }
54
55   // Get the xref table.
56   XRef *getXRef() { return xref; }
57
58   // Get catalog.
59   Catalog *getCatalog() { return catalog; }
60
61   // Get base stream.
62   BaseStream *getBaseStream() { return str; }
63
64   // Get page parameters.
65   double getPageWidth(int page)
66     { return catalog->getPage(page)->getWidth(); }
67   double getPageHeight(int page)
68     { return catalog->getPage(page)->getHeight(); }
69   int getPageRotate(int page)
70     { return catalog->getPage(page)->getRotate(); }
71
72   // Get number of pages.
73   int getNumPages() { return catalog->getNumPages(); }
74
75   // Return the contents of the metadata stream, or NULL if there is
76   // no metadata.
77   GString *readMetadata() { return catalog->readMetadata(); }
78
79   // Return the structure tree root object.
80   Object *getStructTreeRoot() { return catalog->getStructTreeRoot(); }
81
82   // Display a page.
83   void displayPage(OutputDev *out, int page, double hDPI, double vDPI,
84                    int rotate, GBool crop, GBool doLinks,
85                    GBool (*abortCheckCbk)(void *data) = NULL,
86                    void *abortCheckCbkData = NULL,
87                    GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data) = NULL,
88                    void *annotDisplayDecideCbkData = NULL);
89
90   // Display a range of pages.
91   void displayPages(OutputDev *out, int firstPage, int lastPage,
92                     double hDPI, double vDPI, int rotate,
93                     GBool crop, GBool doLinks,
94                     GBool (*abortCheckCbk)(void *data) = NULL,
95                     void *abortCheckCbkData = NULL,
96                     GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data) = NULL,
97                     void *annotDisplayDecideCbkData = NULL);
98
99   // Display part of a page.
100   void displayPageSlice(OutputDev *out, int page,
101                         double hDPI, double vDPI,
102                         int rotate, GBool crop,
103                         int sliceX, int sliceY, int sliceW, int sliceH,
104                         GBool (*abortCheckCbk)(void *data) = NULL,
105                         void *abortCheckCbkData = NULL,
106                         GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data) = NULL,
107                         void *annotDisplayDecideCbkData = NULL);
108
109   // Find a page, given its object ID.  Returns page number, or 0 if
110   // not found.
111   int findPage(int num, int gen) { return catalog->findPage(num, gen); }
112
113   // If point <x>,<y> is in a link, return the associated action;
114   // else return NULL.
115   LinkAction *findLink(double x, double y)
116     { return links ? links->find(x, y) : (LinkAction *)NULL; }
117
118   // Return true if <x>,<y> is in a link.
119   GBool onLink(double x, double y) { return links->onLink(x, y); }
120
121   // Find a named destination.  Returns the link destination, or
122   // NULL if <name> is not a destination.
123   LinkDest *findDest(GString *name)
124     { return catalog->findDest(name); }
125
126 #ifndef DISABLE_OUTLINE
127   // Return the outline object.
128   Outline *getOutline() { return outline; }
129 #endif
130
131   // Is the file encrypted?
132   GBool isEncrypted() { return xref->isEncrypted(); }
133
134   // Check various permissions.
135   GBool okToPrint(GBool ignoreOwnerPW = gFalse)
136     { return xref->okToPrint(ignoreOwnerPW); }
137   GBool okToChange(GBool ignoreOwnerPW = gFalse)
138     { return xref->okToChange(ignoreOwnerPW); }
139   GBool okToCopy(GBool ignoreOwnerPW = gFalse)
140     { return xref->okToCopy(ignoreOwnerPW); }
141   GBool okToAddNotes(GBool ignoreOwnerPW = gFalse)
142     { return xref->okToAddNotes(ignoreOwnerPW); }
143
144   // Is this document linearized?
145   GBool isLinearized();
146
147   // Return the document's Info dictionary (if any).
148   Object *getDocInfo(Object *obj) { return xref->getDocInfo(obj); }
149   Object *getDocInfoNF(Object *obj) { return xref->getDocInfoNF(obj); }
150
151   // Return the PDF version specified by the file.
152   double getPDFVersion() { return pdfVersion; }
153
154   // Save this file with another name.
155   GBool saveAs(GString *name);
156
157 private:
158
159   GBool setup(GString *ownerPassword, GString *userPassword);
160   void checkHeader();
161   void getLinks(Page *page);
162
163   GString *fileName;
164   FILE *file;
165   BaseStream *str;
166   double pdfVersion;
167   XRef *xref;
168   Catalog *catalog;
169   Links *links;
170 #ifndef DISABLE_OUTLINE
171   Outline *outline;
172 #endif
173
174   GBool ok;
175   int errCode;
176 };
177
178 #endif