source: trunk/poppler/mypoppler/poppler/PDFDoc.h @ 2

Last change on this file since 2 was 2, checked in by Eugene Romanenko, 16 years ago

First import

File size: 6.0 KB
Line 
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#ifdef USE_GCC_PRAGMAS
13#pragma interface
14#endif
15
16#include <stdio.h>
17#include "XRef.h"
18#include "Catalog.h"
19#include "Page.h"
20#include "Annot.h"
21
22class GooString;
23class BaseStream;
24class OutputDev;
25class Links;
26class LinkAction;
27class LinkDest;
28class Outline;
29
30//------------------------------------------------------------------------
31// PDFDoc
32//------------------------------------------------------------------------
33
34class PDFDoc {
35public:
36
37  PDFDoc(GooString *fileNameA, GooString *ownerPassword = NULL,
38         GooString *userPassword = NULL, void *guiDataA = NULL);
39
40#ifdef WIN32
41  PDFDoc(wchar_t *fileNameA, int fileNameLen, GooString *ownerPassword = NULL,
42         GooString *userPassword = NULL, void *guiDataA = NULL);
43#endif
44
45  PDFDoc(BaseStream *strA, GooString *ownerPassword = NULL,
46         GooString *userPassword = NULL, void *guiDataA = NULL);
47  ~PDFDoc();
48
49  // Was PDF document successfully opened?
50  GBool isOk() { return ok; }
51
52  // Get the error code (if isOk() returns false).
53  int getErrorCode() { return errCode; }
54
55  // Get file name.
56  GooString *getFileName() { return fileName; }
57
58  // Get the xref table.
59  XRef *getXRef() { return xref; }
60
61  // Get catalog.
62  Catalog *getCatalog() { return catalog; }
63
64  // Get base stream.
65  BaseStream *getBaseStream() { return str; }
66
67  // Get page parameters.
68  double getPageMediaWidth(int page)
69    { return catalog->getPage(page)->getMediaWidth(); }
70  double getPageMediaHeight(int page)
71    { return catalog->getPage(page)->getMediaHeight(); }
72  double getPageCropWidth(int page)
73    { return catalog->getPage(page)->getCropWidth(); }
74  double getPageCropHeight(int page)
75    { return catalog->getPage(page)->getCropHeight(); }
76  int getPageRotate(int page)
77    { return catalog->getPage(page)->getRotate(); }
78
79  // Get number of pages.
80  int getNumPages() { return catalog->getNumPages(); }
81
82  // Return the contents of the metadata stream, or NULL if there is
83  // no metadata.
84  GooString *readMetadata() { return catalog->readMetadata(); }
85
86  // Return the structure tree root object.
87  Object *getStructTreeRoot() { return catalog->getStructTreeRoot(); }
88
89  // Display a page.
90  void displayPage(OutputDev *out, int page, double hDPI, double vDPI,
91                   int rotate, GBool useMediaBox, GBool crop, GBool doLinks,
92                   GBool (*abortCheckCbk)(void *data) = NULL,
93                   void *abortCheckCbkData = NULL,
94                   GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data) = NULL,
95                   void *annotDisplayDecideCbkData = NULL);
96
97  // Display a range of pages.
98  void displayPages(OutputDev *out, int firstPage, int lastPage,
99                    double hDPI, double vDPI, int rotate,
100                    GBool useMediaBox, GBool crop, GBool doLinks,
101                    GBool (*abortCheckCbk)(void *data) = NULL,
102                    void *abortCheckCbkData = NULL,
103                    GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data) = NULL,
104                    void *annotDisplayDecideCbkData = NULL);
105
106  // Display part of a page.
107  void displayPageSlice(OutputDev *out, int page,
108                        double hDPI, double vDPI,
109                        int rotate, GBool useMediaBox, GBool crop, GBool doLinks,
110                        int sliceX, int sliceY, int sliceW, int sliceH,
111                        GBool (*abortCheckCbk)(void *data) = NULL,
112                        void *abortCheckCbkData = NULL,
113                        GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data) = NULL,
114                        void *annotDisplayDecideCbkData = NULL);
115
116  // Find a page, given its object ID.  Returns page number, or 0 if
117  // not found.
118  int findPage(int num, int gen) { return catalog->findPage(num, gen); }
119
120  // Returns the links for the current page, transferring ownership to
121  // the caller.
122  Links *takeLinks();
123
124  // Find a named destination.  Returns the link destination, or
125  // NULL if <name> is not a destination.
126  LinkDest *findDest(UGooString *name)
127    { return catalog->findDest(name); }
128
129#ifndef DISABLE_OUTLINE
130  // Return the outline object.
131  Outline *getOutline() { return outline; }
132#endif
133
134  // Is the file encrypted?
135  GBool isEncrypted() { return xref->isEncrypted(); }
136
137  // Check various permissions.
138  GBool okToPrint(GBool ignoreOwnerPW = gFalse)
139    { return xref->okToPrint(ignoreOwnerPW); }
140  GBool okToPrintHighRes(GBool ignoreOwnerPW = gFalse)
141    { return xref->okToPrintHighRes(ignoreOwnerPW); }
142  GBool okToChange(GBool ignoreOwnerPW = gFalse)
143    { return xref->okToChange(ignoreOwnerPW); }
144  GBool okToCopy(GBool ignoreOwnerPW = gFalse)
145    { return xref->okToCopy(ignoreOwnerPW); }
146  GBool okToAddNotes(GBool ignoreOwnerPW = gFalse)
147    { return xref->okToAddNotes(ignoreOwnerPW); }
148  GBool okToFillForm(GBool ignoreOwnerPW = gFalse)
149    { return xref->okToFillForm(ignoreOwnerPW); }
150  GBool okToAccessibility(GBool ignoreOwnerPW = gFalse)
151    { return xref->okToAccessibility(ignoreOwnerPW); }
152  GBool okToAssemble(GBool ignoreOwnerPW = gFalse)
153    { return xref->okToAssemble(ignoreOwnerPW); }
154
155
156  // Is this document linearized?
157  GBool isLinearized();
158
159  // Return the document's Info dictionary (if any).
160  Object *getDocInfo(Object *obj) { return xref->getDocInfo(obj); }
161  Object *getDocInfoNF(Object *obj) { return xref->getDocInfoNF(obj); }
162
163  // Return the PDF version specified by the file.
164  double getPDFVersion() { return pdfVersion; }
165
166  // Save this file with another name.
167  GBool saveAs(GooString *name);
168
169  // Return a pointer to the GUI (XPDFCore or WinPDFCore object).
170  void *getGUIData() { return guiData; }
171
172private:
173
174  GBool setup(GooString *ownerPassword, GooString *userPassword);
175  GBool checkFooter();
176  void checkHeader();
177  GBool checkEncryption(GooString *ownerPassword, GooString *userPassword);
178  void getLinks(Page *page);
179
180  GooString *fileName;
181  FILE *file;
182  BaseStream *str;
183  void *guiData;
184  double pdfVersion;
185  XRef *xref;
186  Catalog *catalog;
187  Links *links;
188#ifndef DISABLE_OUTLINE
189  Outline *outline;
190#endif
191
192  GBool ok;
193  int errCode;
194};
195
196#endif
Note: See TracBrowser for help on using the repository browser.