]>
git.ipfire.org Git - thirdparty/cups.git/blob - pdftops/Page.h
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
*getMediaBox() { return &mediaBox
; }
55 PDFRectangle
*getCropBox() { return &cropBox
; }
56 GBool
isCropped() { return haveCropBox
; }
57 PDFRectangle
*getBleedBox() { return &bleedBox
; }
58 PDFRectangle
*getTrimBox() { return &trimBox
; }
59 PDFRectangle
*getArtBox() { return &artBox
; }
60 int getRotate() { return rotate
; }
61 GString
*getLastModified()
62 { return lastModified
.isString()
63 ? lastModified
.getString() : (GString
*)NULL
; }
64 Dict
*getBoxColorInfo()
65 { return boxColorInfo
.isDict() ? boxColorInfo
.getDict() : (Dict
*)NULL
; }
67 { return group
.isDict() ? group
.getDict() : (Dict
*)NULL
; }
69 { return metadata
.isStream() ? metadata
.getStream() : (Stream
*)NULL
; }
71 { return pieceInfo
.isDict() ? pieceInfo
.getDict() : (Dict
*)NULL
; }
72 Dict
*getSeparationInfo()
73 { return separationInfo
.isDict()
74 ? separationInfo
.getDict() : (Dict
*)NULL
; }
75 Dict
*getResourceDict()
76 { return resources
.isDict() ? resources
.getDict() : (Dict
*)NULL
; }
80 GBool
readBox(Dict
*dict
, char *key
, PDFRectangle
*box
);
82 PDFRectangle mediaBox
;
85 PDFRectangle bleedBox
;
94 Object separationInfo
;
98 //------------------------------------------------------------------------
100 //------------------------------------------------------------------------
106 Page(XRef
*xrefA
, int numA
, Dict
*pageDict
, PageAttrs
*attrsA
);
112 GBool
isOk() { return ok
; }
114 // Get page parameters.
115 PDFRectangle
*getMediaBox() { return attrs
->getMediaBox(); }
116 PDFRectangle
*getCropBox() { return attrs
->getCropBox(); }
117 GBool
isCropped() { return attrs
->isCropped(); }
118 double getMediaWidth()
119 { return attrs
->getMediaBox()->x2
- attrs
->getMediaBox()->x1
; }
120 double getMediaHeight()
121 { return attrs
->getMediaBox()->y2
- attrs
->getMediaBox()->y1
; }
122 double getCropWidth()
123 { return attrs
->getCropBox()->x2
- attrs
->getCropBox()->x1
; }
124 double getCropHeight()
125 { return attrs
->getCropBox()->y2
- attrs
->getCropBox()->y1
; }
126 PDFRectangle
*getBleedBox() { return attrs
->getBleedBox(); }
127 PDFRectangle
*getTrimBox() { return attrs
->getTrimBox(); }
128 PDFRectangle
*getArtBox() { return attrs
->getArtBox(); }
129 int getRotate() { return attrs
->getRotate(); }
130 GString
*getLastModified() { return attrs
->getLastModified(); }
131 Dict
*getBoxColorInfo() { return attrs
->getBoxColorInfo(); }
132 Dict
*getGroup() { return attrs
->getGroup(); }
133 Stream
*getMetadata() { return attrs
->getMetadata(); }
134 Dict
*getPieceInfo() { return attrs
->getPieceInfo(); }
135 Dict
*getSeparationInfo() { return attrs
->getSeparationInfo(); }
137 // Get resource dictionary.
138 Dict
*getResourceDict() { return attrs
->getResourceDict(); }
140 // Get annotations array.
141 Object
*getAnnots(Object
*obj
) { return annots
.fetch(xref
, obj
); }
144 Object
*getContents(Object
*obj
) { return contents
.fetch(xref
, obj
); }
147 void display(OutputDev
*out
, double hDPI
, double vDPI
,
148 int rotate
, GBool useMediaBox
, GBool crop
,
149 Links
*links
, Catalog
*catalog
,
150 GBool (*abortCheckCbk
)(void *data
) = NULL
,
151 void *abortCheckCbkData
= NULL
);
153 // Display part of a page.
154 void displaySlice(OutputDev
*out
, double hDPI
, double vDPI
,
155 int rotate
, GBool useMediaBox
, GBool crop
,
156 int sliceX
, int sliceY
, int sliceW
, int sliceH
,
157 Links
*links
, Catalog
*catalog
,
158 GBool (*abortCheckCbk
)(void *data
) = NULL
,
159 void *abortCheckCbkData
= NULL
);
161 // Get the page's default CTM.
162 void getDefaultCTM(double *ctm
, double hDPI
, double vDPI
,
163 int rotate
, GBool upsideDown
);
167 XRef
*xref
; // the xref table for this PDF file
168 int num
; // page number
169 PageAttrs
*attrs
; // page attributes
170 Object annots
; // annotations array
171 Object contents
; // page contents
172 GBool ok
; // true if page is valid