1 //========================================================================
5 // Copyright 1996-2003 Glyph & Cog, LLC
7 //========================================================================
14 #ifdef USE_GCC_PRAGMAS
30 class GfxTilingPattern;
31 class GfxShadingPattern;
33 class GfxFunctionShading;
34 class GfxAxialShading;
35 class GfxRadialShading;
36 class GfxGouraudTriangleShading;
37 class GfxPatchMeshShading;
44 //------------------------------------------------------------------------
46 //------------------------------------------------------------------------
57 tchkNum, // number (integer or real)
61 tchkProps, // properties (dictionary or name)
62 tchkSCN, // scn/SCN args (number of name)
63 tchkNone // used to avoid empty initializer lists
71 TchkType tchk[maxArgs];
72 void (Gfx::*func)(Object args[], int numArgs);
78 GfxResources(XRef *xref, Dict *resDict, GfxResources *nextA);
81 GfxFont *lookupFont(char *name);
82 GBool lookupXObject(char *name, Object *obj);
83 GBool lookupXObjectNF(char *name, Object *obj);
84 void lookupColorSpace(char *name, Object *obj);
85 GfxPattern *lookupPattern(char *name);
86 GfxShading *lookupShading(char *name);
87 GBool lookupGState(char *name, Object *obj);
89 GfxResources *getNext() { return next; }
95 Object colorSpaceDict;
105 // Constructor for regular output.
106 Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict,
107 double hDPI, double vDPI, PDFRectangle *box,
108 PDFRectangle *cropBox, int rotate,
109 GBool (*abortCheckCbkA)(void *data) = NULL,
110 void *abortCheckCbkDataA = NULL);
112 // Constructor for a sub-page object.
113 Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict,
114 PDFRectangle *box, PDFRectangle *cropBox,
115 GBool (*abortCheckCbkA)(void *data) = NULL,
116 void *abortCheckCbkDataA = NULL);
120 // Interpret a stream or array of streams.
121 void display(Object *obj, GBool topLevel = gTrue);
123 // Display an annotation, given its appearance (a Form XObject) and
124 // bounding box (in default user space).
125 void doAnnot(Object *str, double xMin, double yMin,
126 double xMax, double yMax);
128 // Save graphics state.
131 // Restore graphics state.
134 // Get the current graphics state object.
135 GfxState *getState() { return state; }
139 XRef *xref; // the xref table for this PDF file
140 OutputDev *out; // output device
141 GBool subPage; // is this a sub-page object?
142 GBool printCommands; // print the drawing commands (for debugging)
143 GfxResources *res; // resource stack
146 GfxState *state; // current graphics state
147 GBool fontChanged; // set if font or text matrix has changed
148 GfxClipType clip; // do a clip?
149 int ignoreUndef; // current BX/EX nesting level
150 double baseMatrix[6]; // default matrix for most recent
154 Parser *parser; // parser for page content stream(s)
156 GBool // callback to check for an abort
157 (*abortCheckCbk)(void *data);
158 void *abortCheckCbkData;
160 static Operator opTab[]; // table of operators
162 void go(GBool topLevel);
163 void execOp(Object *cmd, Object args[], int numArgs);
164 Operator *findOp(char *name);
165 GBool checkArg(Object *arg, TchkType type);
168 // graphics state operators
169 void opSave(Object args[], int numArgs);
170 void opRestore(Object args[], int numArgs);
171 void opConcat(Object args[], int numArgs);
172 void opSetDash(Object args[], int numArgs);
173 void opSetFlat(Object args[], int numArgs);
174 void opSetLineJoin(Object args[], int numArgs);
175 void opSetLineCap(Object args[], int numArgs);
176 void opSetMiterLimit(Object args[], int numArgs);
177 void opSetLineWidth(Object args[], int numArgs);
178 void opSetExtGState(Object args[], int numArgs);
179 void opSetRenderingIntent(Object args[], int numArgs);
182 void opSetFillGray(Object args[], int numArgs);
183 void opSetStrokeGray(Object args[], int numArgs);
184 void opSetFillCMYKColor(Object args[], int numArgs);
185 void opSetStrokeCMYKColor(Object args[], int numArgs);
186 void opSetFillRGBColor(Object args[], int numArgs);
187 void opSetStrokeRGBColor(Object args[], int numArgs);
188 void opSetFillColorSpace(Object args[], int numArgs);
189 void opSetStrokeColorSpace(Object args[], int numArgs);
190 void opSetFillColor(Object args[], int numArgs);
191 void opSetStrokeColor(Object args[], int numArgs);
192 void opSetFillColorN(Object args[], int numArgs);
193 void opSetStrokeColorN(Object args[], int numArgs);
195 // path segment operators
196 void opMoveTo(Object args[], int numArgs);
197 void opLineTo(Object args[], int numArgs);
198 void opCurveTo(Object args[], int numArgs);
199 void opCurveTo1(Object args[], int numArgs);
200 void opCurveTo2(Object args[], int numArgs);
201 void opRectangle(Object args[], int numArgs);
202 void opClosePath(Object args[], int numArgs);
204 // path painting operators
205 void opEndPath(Object args[], int numArgs);
206 void opStroke(Object args[], int numArgs);
207 void opCloseStroke(Object args[], int numArgs);
208 void opFill(Object args[], int numArgs);
209 void opEOFill(Object args[], int numArgs);
210 void opFillStroke(Object args[], int numArgs);
211 void opCloseFillStroke(Object args[], int numArgs);
212 void opEOFillStroke(Object args[], int numArgs);
213 void opCloseEOFillStroke(Object args[], int numArgs);
214 void doPatternFill(GBool eoFill);
215 void doTilingPatternFill(GfxTilingPattern *tPat, GBool eoFill);
216 void doShadingPatternFill(GfxShadingPattern *sPat, GBool eoFill);
217 void opShFill(Object args[], int numArgs);
218 void doFunctionShFill(GfxFunctionShading *shading);
219 void doFunctionShFill1(GfxFunctionShading *shading,
220 double x0, double y0,
221 double x1, double y1,
222 GfxColor *colors, int depth);
223 void doAxialShFill(GfxAxialShading *shading);
224 void doRadialShFill(GfxRadialShading *shading);
225 void doGouraudTriangleShFill(GfxGouraudTriangleShading *shading);
226 void gouraudFillTriangle(double x0, double y0, GfxColor *color0,
227 double x1, double y1, GfxColor *color1,
228 double x2, double y2, GfxColor *color2,
229 int nComps, int depth);
230 void doPatchMeshShFill(GfxPatchMeshShading *shading);
231 void fillPatch(GfxPatch *patch, int nComps, int depth);
234 // path clipping operators
235 void opClip(Object args[], int numArgs);
236 void opEOClip(Object args[], int numArgs);
238 // text object operators
239 void opBeginText(Object args[], int numArgs);
240 void opEndText(Object args[], int numArgs);
242 // text state operators
243 void opSetCharSpacing(Object args[], int numArgs);
244 void opSetFont(Object args[], int numArgs);
245 void opSetTextLeading(Object args[], int numArgs);
246 void opSetTextRender(Object args[], int numArgs);
247 void opSetTextRise(Object args[], int numArgs);
248 void opSetWordSpacing(Object args[], int numArgs);
249 void opSetHorizScaling(Object args[], int numArgs);
251 // text positioning operators
252 void opTextMove(Object args[], int numArgs);
253 void opTextMoveSet(Object args[], int numArgs);
254 void opSetTextMatrix(Object args[], int numArgs);
255 void opTextNextLine(Object args[], int numArgs);
257 // text string operators
258 void opShowText(Object args[], int numArgs);
259 void opMoveShowText(Object args[], int numArgs);
260 void opMoveSetShowText(Object args[], int numArgs);
261 void opShowSpaceText(Object args[], int numArgs);
262 void doShowText(GString *s);
265 void opXObject(Object args[], int numArgs);
266 void doImage(Object *ref, Stream *str, GBool inlineImg);
267 void doForm(Object *str);
268 void doForm1(Object *str, Dict *resDict, double *matrix, double *bbox);
270 // in-line image operators
271 void opBeginImage(Object args[], int numArgs);
272 Stream *buildImageStream();
273 void opImageData(Object args[], int numArgs);
274 void opEndImage(Object args[], int numArgs);
276 // type 3 font operators
277 void opSetCharWidth(Object args[], int numArgs);
278 void opSetCacheDevice(Object args[], int numArgs);
280 // compatibility operators
281 void opBeginIgnoreUndef(Object args[], int numArgs);
282 void opEndIgnoreUndef(Object args[], int numArgs);
284 // marked content operators
285 void opBeginMarkedContent(Object args[], int numArgs);
286 void opEndMarkedContent(Object args[], int numArgs);
287 void opMarkPoint(Object args[], int numArgs);
289 void pushResources(Dict *resDict);