1 //========================================================================
5 // Copyright 1996-2003 Glyph & Cog, LLC
7 //========================================================================
14 #ifdef USE_GCC_PRAGMAS
28 //------------------------------------------------------------------------
32 double x1, y1, x2, y2;
34 PDFRectangle() { x1 = y1 = x2 = y2 = 0; }
35 PDFRectangle(double x1A, double y1A, double x2A, double y2A)
36 { x1 = x1A; y1 = y1A; x2 = x2A; y2 = y2A; }
37 GBool isValid() { return x1 != 0 || y1 != 0 || x2 != 0 || y2 != 0; }
40 //------------------------------------------------------------------------
42 //------------------------------------------------------------------------
47 // Construct a new PageAttrs object by merging a dictionary
48 // (of type Pages or Page) into another PageAttrs object. If
49 // <attrs> is NULL, uses defaults.
50 PageAttrs(PageAttrs *attrs, Dict *dict);
56 PDFRectangle *getBox() { return limitToCropBox ? &cropBox : &mediaBox; }
57 PDFRectangle *getMediaBox() { return &mediaBox; }
58 PDFRectangle *getCropBox() { return &cropBox; }
59 GBool isCropped() { return haveCropBox; }
60 PDFRectangle *getBleedBox() { return &bleedBox; }
61 PDFRectangle *getTrimBox() { return &trimBox; }
62 PDFRectangle *getArtBox() { return &artBox; }
63 int getRotate() { return rotate; }
64 GString *getLastModified()
65 { return lastModified.isString()
66 ? lastModified.getString() : (GString *)NULL; }
67 Dict *getBoxColorInfo()
68 { return boxColorInfo.isDict() ? boxColorInfo.getDict() : (Dict *)NULL; }
70 { return group.isDict() ? group.getDict() : (Dict *)NULL; }
72 { return metadata.isStream() ? metadata.getStream() : (Stream *)NULL; }
74 { return pieceInfo.isDict() ? pieceInfo.getDict() : (Dict *)NULL; }
75 Dict *getSeparationInfo()
76 { return separationInfo.isDict()
77 ? separationInfo.getDict() : (Dict *)NULL; }
78 Dict *getResourceDict()
79 { return resources.isDict() ? resources.getDict() : (Dict *)NULL; }
83 GBool readBox(Dict *dict, char *key, PDFRectangle *box);
85 PDFRectangle mediaBox;
89 PDFRectangle bleedBox;
98 Object separationInfo;
102 //------------------------------------------------------------------------
104 //------------------------------------------------------------------------
110 Page(XRef *xrefA, int numA, Dict *pageDict, PageAttrs *attrsA);
116 GBool isOk() { return ok; }
118 // Get page parameters.
119 PDFRectangle *getBox() { return attrs->getBox(); }
120 PDFRectangle *getMediaBox() { return attrs->getMediaBox(); }
121 PDFRectangle *getCropBox() { return attrs->getCropBox(); }
122 GBool isCropped() { return attrs->isCropped(); }
123 double getWidth() { return attrs->getBox()->x2 - attrs->getBox()->x1; }
124 double getHeight() { return attrs->getBox()->y2 - attrs->getBox()->y1; }
125 PDFRectangle *getBleedBox() { return attrs->getBleedBox(); }
126 PDFRectangle *getTrimBox() { return attrs->getTrimBox(); }
127 PDFRectangle *getArtBox() { return attrs->getArtBox(); }
128 int getRotate() { return attrs->getRotate(); }
129 GString *getLastModified() { return attrs->getLastModified(); }
130 Dict *getBoxColorInfo() { return attrs->getBoxColorInfo(); }
131 Dict *getGroup() { return attrs->getGroup(); }
132 Stream *getMetadata() { return attrs->getMetadata(); }
133 Dict *getPieceInfo() { return attrs->getPieceInfo(); }
134 Dict *getSeparationInfo() { return attrs->getSeparationInfo(); }
136 // Get resource dictionary.
137 Dict *getResourceDict() { return attrs->getResourceDict(); }
139 // Get annotations array.
140 Object *getAnnots(Object *obj) { return annots.fetch(xref, obj); }
143 Object *getContents(Object *obj) { return contents.fetch(xref, obj); }
146 Object *getThumb(Object *obj) { return thumb.fetch(xref, obj); }
149 void display(OutputDev *out, double hDPI, double vDPI,
150 int rotate, GBool crop,
151 Links *links, Catalog *catalog,
152 GBool (*abortCheckCbk)(void *data) = NULL,
153 void *abortCheckCbkData = NULL,
154 GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data) = NULL,
155 void *annotDisplayDecideCbkData = NULL);
157 // Display part of a page.
158 void displaySlice(OutputDev *out, double hDPI, double vDPI,
159 int rotate, GBool crop,
160 int sliceX, int sliceY, int sliceW, int sliceH,
161 Links *links, Catalog *catalog,
162 GBool (*abortCheckCbk)(void *data) = NULL,
163 void *abortCheckCbkData = NULL,
164 GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data) = NULL,
165 void *annotDisplayDecideCbkData = NULL);
169 XRef *xref; // the xref table for this PDF file
170 int num; // page number
171 PageAttrs *attrs; // page attributes
172 Object annots; // annotations array
173 Object contents; // page contents
174 Object thumb; // page thumbnail
175 GBool ok; // true if page is valid