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; }
36 void clipTo(PDFRectangle
*rect
);
39 //------------------------------------------------------------------------
41 //------------------------------------------------------------------------
46 // Construct a new PageAttrs xObject by merging a dictionary
47 // (of type Pages or Page) into another PageAttrs xObject. If
48 // <attrs> is NULL, uses defaults.
49 PageAttrs(PageAttrs
*attrs
, Dict
*dict
);
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
;
86 PDFRectangle bleedBox
;
95 xObject separationInfo
;
99 //------------------------------------------------------------------------
101 //------------------------------------------------------------------------
107 Page(XRef
*xrefA
, int numA
, Dict
*pageDict
, PageAttrs
*attrsA
);
113 GBool
isOk() { return ok
; }
115 // Get page parameters.
116 int getNum() { return num
; }
117 PDFRectangle
*getMediaBox() { return attrs
->getMediaBox(); }
118 PDFRectangle
*getCropBox() { return attrs
->getCropBox(); }
119 GBool
isCropped() { return attrs
->isCropped(); }
120 double getMediaWidth()
121 { return attrs
->getMediaBox()->x2
- attrs
->getMediaBox()->x1
; }
122 double getMediaHeight()
123 { return attrs
->getMediaBox()->y2
- attrs
->getMediaBox()->y1
; }
124 double getCropWidth()
125 { return attrs
->getCropBox()->x2
- attrs
->getCropBox()->x1
; }
126 double getCropHeight()
127 { return attrs
->getCropBox()->y2
- attrs
->getCropBox()->y1
; }
128 PDFRectangle
*getBleedBox() { return attrs
->getBleedBox(); }
129 PDFRectangle
*getTrimBox() { return attrs
->getTrimBox(); }
130 PDFRectangle
*getArtBox() { return attrs
->getArtBox(); }
131 int getRotate() { return attrs
->getRotate(); }
132 GString
*getLastModified() { return attrs
->getLastModified(); }
133 Dict
*getBoxColorInfo() { return attrs
->getBoxColorInfo(); }
134 Dict
*getGroup() { return attrs
->getGroup(); }
135 Stream
*getMetadata() { return attrs
->getMetadata(); }
136 Dict
*getPieceInfo() { return attrs
->getPieceInfo(); }
137 Dict
*getSeparationInfo() { return attrs
->getSeparationInfo(); }
139 // Get resource dictionary.
140 Dict
*getResourceDict() { return attrs
->getResourceDict(); }
142 // Get annotations array.
143 xObject
*getAnnots(xObject
*obj
) { return annots
.fetch(xref
, obj
); }
145 // Return a list of links.
146 Links
*getLinks(Catalog
*catalog
);
149 xObject
*getContents(xObject
*obj
) { return contents
.fetch(xref
, obj
); }
152 void display(OutputDev
*out
, double hDPI
, double vDPI
,
153 int rotate
, GBool useMediaBox
, GBool crop
,
154 GBool printing
, Catalog
*catalog
,
155 GBool (*abortCheckCbk
)(void *data
) = NULL
,
156 void *abortCheckCbkData
= NULL
);
158 // Display part of a page.
159 void displaySlice(OutputDev
*out
, double hDPI
, double vDPI
,
160 int rotate
, GBool useMediaBox
, GBool crop
,
161 int sliceX
, int sliceY
, int sliceW
, int sliceH
,
162 GBool printing
, Catalog
*catalog
,
163 GBool (*abortCheckCbk
)(void *data
) = NULL
,
164 void *abortCheckCbkData
= NULL
);
166 void makeBox(double hDPI
, double vDPI
, int rotate
,
167 GBool useMediaBox
, GBool upsideDown
,
168 double sliceX
, double sliceY
, double sliceW
, double sliceH
,
169 PDFRectangle
*box
, GBool
*crop
);
171 void processLinks(OutputDev
*out
, Catalog
*catalog
);
173 // Get the page's default CTM.
174 void getDefaultCTM(double *ctm
, double hDPI
, double vDPI
,
175 int rotate
, GBool useMediaBox
, GBool upsideDown
);
179 XRef
*xref
; // the xref table for this PDF file
180 int num
; // page number
181 PageAttrs
*attrs
; // page attributes
182 xObject annots
; // annotations array
183 xObject contents
; // page contents
184 GBool ok
; // true if page is valid