1 //========================================================================
5 // Copyright 1996-2003 Glyph & Cog, LLC
7 //========================================================================
14 #ifdef USE_GCC_PRAGMAS
26 //------------------------------------------------------------------------
30 double x1, y1, x2, y2;
32 PDFRectangle() { x1 = y1 = x2 = y2 = 0; }
33 PDFRectangle(double x1A, double y1A, double x2A, double y2A)
34 { x1 = x1A; y1 = y1A; x2 = x2A; y2 = y2A; }
35 GBool isValid() { return x1 != 0 || y1 != 0 || x2 != 0 || y2 != 0; }
38 //------------------------------------------------------------------------
40 //------------------------------------------------------------------------
45 // Construct a new PageAttrs object by merging a dictionary
46 // (of type Pages or Page) into another PageAttrs object. If
47 // <attrs> is NULL, uses defaults.
48 PageAttrs(PageAttrs *attrs, Dict *dict);
54 PDFRectangle *getBox() { return limitToCropBox ? &cropBox : &mediaBox; }
55 PDFRectangle *getMediaBox() { return &mediaBox; }
56 PDFRectangle *getCropBox() { return &cropBox; }
57 GBool isCropped() { return haveCropBox; }
58 PDFRectangle *getBleedBox() { return &bleedBox; }
59 PDFRectangle *getTrimBox() { return &trimBox; }
60 PDFRectangle *getArtBox() { return &artBox; }
61 int getRotate() { return rotate; }
62 GString *getLastModified()
63 { return lastModified.isString()
64 ? lastModified.getString() : (GString *)NULL; }
65 Dict *getBoxColorInfo()
66 { return boxColorInfo.isDict() ? boxColorInfo.getDict() : (Dict *)NULL; }
68 { return group.isDict() ? group.getDict() : (Dict *)NULL; }
70 { return metadata.isStream() ? metadata.getStream() : (Stream *)NULL; }
72 { return pieceInfo.isDict() ? pieceInfo.getDict() : (Dict *)NULL; }
73 Dict *getSeparationInfo()
74 { return separationInfo.isDict()
75 ? separationInfo.getDict() : (Dict *)NULL; }
76 Dict *getResourceDict()
77 { return resources.isDict() ? resources.getDict() : (Dict *)NULL; }
81 GBool readBox(Dict *dict, char *key, PDFRectangle *box);
83 PDFRectangle mediaBox;
87 PDFRectangle bleedBox;
96 Object separationInfo;
100 //------------------------------------------------------------------------
102 //------------------------------------------------------------------------
108 Page(XRef *xrefA, int numA, Dict *pageDict, PageAttrs *attrsA);
114 GBool isOk() { return ok; }
116 // Get page parameters.
117 PDFRectangle *getBox() { return attrs->getBox(); }
118 PDFRectangle *getMediaBox() { return attrs->getMediaBox(); }
119 PDFRectangle *getCropBox() { return attrs->getCropBox(); }
120 GBool isCropped() { return attrs->isCropped(); }
121 double getWidth() { return attrs->getBox()->x2 - attrs->getBox()->x1; }
122 double getHeight() { return attrs->getBox()->y2 - attrs->getBox()->y1; }
123 PDFRectangle *getBleedBox() { return attrs->getBleedBox(); }
124 PDFRectangle *getTrimBox() { return attrs->getTrimBox(); }
125 PDFRectangle *getArtBox() { return attrs->getArtBox(); }
126 int getRotate() { return attrs->getRotate(); }
127 GString *getLastModified() { return attrs->getLastModified(); }
128 Dict *getBoxColorInfo() { return attrs->getBoxColorInfo(); }
129 Dict *getGroup() { return attrs->getGroup(); }
130 Stream *getMetadata() { return attrs->getMetadata(); }
131 Dict *getPieceInfo() { return attrs->getPieceInfo(); }
132 Dict *getSeparationInfo() { return attrs->getSeparationInfo(); }
134 // Get resource dictionary.
135 Dict *getResourceDict() { return attrs->getResourceDict(); }
137 // Get annotations array.
138 Object *getAnnots(Object *obj) { return annots.fetch(xref, obj); }
141 Object *getContents(Object *obj) { return contents.fetch(xref, obj); }
144 void display(OutputDev *out, double hDPI, double vDPI,
145 int rotate, GBool crop,
146 Links *links, Catalog *catalog,
147 GBool (*abortCheckCbk)(void *data) = NULL,
148 void *abortCheckCbkData = NULL);
150 // Display part of a page.
151 void displaySlice(OutputDev *out, double hDPI, double vDPI,
152 int rotate, GBool crop,
153 int sliceX, int sliceY, int sliceW, int sliceH,
154 Links *links, Catalog *catalog,
155 GBool (*abortCheckCbk)(void *data) = NULL,
156 void *abortCheckCbkData = NULL);
160 XRef *xref; // the xref table for this PDF file
161 int num; // page number
162 PageAttrs *attrs; // page attributes
163 Object annots; // annotations array
164 Object contents; // page contents
165 GBool ok; // true if page is valid