1 //========================================================================
5 // Copyright 1996-2003 Glyph & Cog, LLC
7 //========================================================================
14 #ifdef USE_GCC_PRAGMAS
31 class GfxTilingPattern;
32 class GfxShadingPattern;
34 class GfxFunctionShading;
35 class GfxAxialShading;
36 class GfxRadialShading;
42 //------------------------------------------------------------------------
44 //------------------------------------------------------------------------
55 tchkNum, // number (integer or real)
59 tchkProps, // properties (dictionary or name)
60 tchkSCN, // scn/SCN args (number of name)
61 tchkNone // used to avoid empty initializer lists
69 TchkType tchk[maxArgs];
70 void (Gfx::*func)(Object args[], int numArgs);
76 GfxResources(XRef *xref, Dict *resDict, GfxResources *nextA);
79 GfxFont *lookupFont(char *name);
80 GBool lookupXObject(char *name, Object *obj);
81 GBool lookupXObjectNF(char *name, Object *obj);
82 void lookupColorSpace(char *name, Object *obj);
83 GfxPattern *lookupPattern(char *name);
84 GfxShading *lookupShading(char *name);
85 GBool lookupGState(char *name, Object *obj);
87 GfxResources *getNext() { return next; }
93 Object colorSpaceDict;
103 // Constructor for regular output.
104 Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict,
105 double hDPI, double vDPI, PDFRectangle *box, GBool crop,
106 PDFRectangle *cropBox, int rotate,
107 GBool (*abortCheckCbkA)(void *data) = NULL,
108 void *abortCheckCbkDataA = NULL);
110 // Constructor for a sub-page object.
111 Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict,
112 PDFRectangle *box, GBool crop, PDFRectangle *cropBox,
113 GBool (*abortCheckCbkA)(void *data) = NULL,
114 void *abortCheckCbkDataA = NULL);
118 // Interpret a stream or array of streams.
119 void display(Object *obj, GBool topLevel = gTrue);
121 // Display an annotation, given its appearance (a Form XObject) and
122 // bounding box (in default user space).
123 void doAnnot(Object *str, double xMin, double yMin,
124 double xMax, double yMax);
126 // Save graphics state.
129 // Restore graphics state.
134 XRef *xref; // the xref table for this PDF file
135 OutputDev *out; // output device
136 GBool subPage; // is this a sub-page object?
137 GBool printCommands; // print the drawing commands (for debugging)
138 GfxResources *res; // resource stack
141 GfxState *state; // current graphics state
142 GBool fontChanged; // set if font or text matrix has changed
143 GfxClipType clip; // do a clip?
144 int ignoreUndef; // current BX/EX nesting level
145 double baseMatrix[6]; // default matrix for most recent
149 Parser *parser; // parser for page content stream(s)
151 GBool // callback to check for an abort
152 (*abortCheckCbk)(void *data);
153 void *abortCheckCbkData;
155 static Operator opTab[]; // table of operators
157 void go(GBool topLevel);
158 void execOp(Object *cmd, Object args[], int numArgs);
159 Operator *findOp(char *name);
160 GBool checkArg(Object *arg, TchkType type);
163 // graphics state operators
164 void opSave(Object args[], int numArgs);
165 void opRestore(Object args[], int numArgs);
166 void opConcat(Object args[], int numArgs);
167 void opSetDash(Object args[], int numArgs);
168 void opSetFlat(Object args[], int numArgs);
169 void opSetLineJoin(Object args[], int numArgs);
170 void opSetLineCap(Object args[], int numArgs);
171 void opSetMiterLimit(Object args[], int numArgs);
172 void opSetLineWidth(Object args[], int numArgs);
173 void opSetExtGState(Object args[], int numArgs);
174 void opSetRenderingIntent(Object args[], int numArgs);
177 void opSetFillGray(Object args[], int numArgs);
178 void opSetStrokeGray(Object args[], int numArgs);
179 void opSetFillCMYKColor(Object args[], int numArgs);
180 void opSetStrokeCMYKColor(Object args[], int numArgs);
181 void opSetFillRGBColor(Object args[], int numArgs);
182 void opSetStrokeRGBColor(Object args[], int numArgs);
183 void opSetFillColorSpace(Object args[], int numArgs);
184 void opSetStrokeColorSpace(Object args[], int numArgs);
185 void opSetFillColor(Object args[], int numArgs);
186 void opSetStrokeColor(Object args[], int numArgs);
187 void opSetFillColorN(Object args[], int numArgs);
188 void opSetStrokeColorN(Object args[], int numArgs);
190 // path segment operators
191 void opMoveTo(Object args[], int numArgs);
192 void opLineTo(Object args[], int numArgs);
193 void opCurveTo(Object args[], int numArgs);
194 void opCurveTo1(Object args[], int numArgs);
195 void opCurveTo2(Object args[], int numArgs);
196 void opRectangle(Object args[], int numArgs);
197 void opClosePath(Object args[], int numArgs);
199 // path painting operators
200 void opEndPath(Object args[], int numArgs);
201 void opStroke(Object args[], int numArgs);
202 void opCloseStroke(Object args[], int numArgs);
203 void opFill(Object args[], int numArgs);
204 void opEOFill(Object args[], int numArgs);
205 void opFillStroke(Object args[], int numArgs);
206 void opCloseFillStroke(Object args[], int numArgs);
207 void opEOFillStroke(Object args[], int numArgs);
208 void opCloseEOFillStroke(Object args[], int numArgs);
209 void doPatternFill(GBool eoFill);
210 void doTilingPatternFill(GfxTilingPattern *tPat, GBool eoFill);
211 void doShadingPatternFill(GfxShadingPattern *sPat, GBool eoFill);
212 void opShFill(Object args[], int numArgs);
213 void doFunctionShFill(GfxFunctionShading *shading);
214 void doFunctionShFill1(GfxFunctionShading *shading,
215 double x0, double y0,
216 double x1, double y1,
217 GfxColor *colors, int depth);
218 void doAxialShFill(GfxAxialShading *shading);
219 void doRadialShFill(GfxRadialShading *shading);
222 // path clipping operators
223 void opClip(Object args[], int numArgs);
224 void opEOClip(Object args[], int numArgs);
226 // text object operators
227 void opBeginText(Object args[], int numArgs);
228 void opEndText(Object args[], int numArgs);
230 // text state operators
231 void opSetCharSpacing(Object args[], int numArgs);
232 void opSetFont(Object args[], int numArgs);
233 void opSetTextLeading(Object args[], int numArgs);
234 void opSetTextRender(Object args[], int numArgs);
235 void opSetTextRise(Object args[], int numArgs);
236 void opSetWordSpacing(Object args[], int numArgs);
237 void opSetHorizScaling(Object args[], int numArgs);
239 // text positioning operators
240 void opTextMove(Object args[], int numArgs);
241 void opTextMoveSet(Object args[], int numArgs);
242 void opSetTextMatrix(Object args[], int numArgs);
243 void opTextNextLine(Object args[], int numArgs);
245 // text string operators
246 void opShowText(Object args[], int numArgs);
247 void opMoveShowText(Object args[], int numArgs);
248 void opMoveSetShowText(Object args[], int numArgs);
249 void opShowSpaceText(Object args[], int numArgs);
250 void doShowText(GString *s);
253 void opXObject(Object args[], int numArgs);
254 void doImage(Object *ref, Stream *str, GBool inlineImg);
255 void doForm(Object *str);
256 void doForm1(Object *str, Dict *resDict, double *matrix, double *bbox);
258 // in-line image operators
259 void opBeginImage(Object args[], int numArgs);
260 Stream *buildImageStream();
261 void opImageData(Object args[], int numArgs);
262 void opEndImage(Object args[], int numArgs);
264 // type 3 font operators
265 void opSetCharWidth(Object args[], int numArgs);
266 void opSetCacheDevice(Object args[], int numArgs);
268 // compatibility operators
269 void opBeginIgnoreUndef(Object args[], int numArgs);
270 void opEndIgnoreUndef(Object args[], int numArgs);
272 // marked content operators
273 void opBeginMarkedContent(Object args[], int numArgs);
274 void opEndMarkedContent(Object args[], int numArgs);
275 void opMarkPoint(Object args[], int numArgs);
277 void pushResources(Dict *resDict);