1 #ifndef __gfxoutputdev_h__
2 #define __gfxoutputdev_h__
4 #include "../gfxdevice.h"
5 #include "../gfxsource.h"
7 #include "InfoOutputDev.h"
10 typedef struct _fontlist
17 class GFXOutputState {
22 char transparencygroup;
27 gfxresult_t* grouprecording; // for transparency groups
28 gfxresult_t* softmaskrecording; // for soft masks
30 gfxdevice_t* olddevice;
33 typedef struct _parameter
37 struct _parameter*next;
40 void addGlobalFont(char*filename);
41 void addGlobalLanguageDir(char*dir);
42 void addGlobalFontDir(char*dirname);
44 class GFXOutputDev: public OutputDev {
49 GFXOutputDev(parameter_t*p);
50 void setDevice(gfxdevice_t*dev);
53 virtual ~GFXOutputDev() ;
55 void setMove(int x,int y);
56 void setClip(int x1,int y1,int x2,int y2);
58 void setInfo(InfoOutputDev*info) {this->info = info;}
61 void startFrame(int width, int height);
63 virtual void startPage(int pageNum, GfxState *state, double x1, double y1, double x2, double y2) ;
67 //----- get info about output device
69 // Does this device use upside-down coordinates?
70 // (Upside-down means (0,0) is the top left corner of the page.)
71 virtual GBool upsideDown();
73 // Does this device use drawChar() or drawString()?
74 virtual GBool useDrawChar();
76 virtual GBool interpretType3Chars();
78 //virtual GBool useShadedFills() { return gTrue; }
80 //----- initialization and control
82 void setXRef(PDFDoc*doc, XRef *xref);
85 virtual void processLink(Link *link, Catalog *catalog);
87 //----- save/restore graphics state
88 virtual void saveState(GfxState *state) ;
89 virtual void restoreState(GfxState *state) ;
91 //----- update graphics state
93 virtual void updateFont(GfxState *state);
94 virtual void updateFillColor(GfxState *state);
95 virtual void updateStrokeColor(GfxState *state);
96 virtual void updateLineWidth(GfxState *state);
97 virtual void updateLineJoin(GfxState *state);
98 virtual void updateLineCap(GfxState *state);
99 virtual void updateFillOpacity(GfxState *state);
100 virtual void updateStrokeOpacity(GfxState *state);
101 virtual void updateFillOverprint(GfxState *state);
102 virtual void updateStrokeOverprint(GfxState *state);
103 virtual void updateTransfer(GfxState *state);
105 virtual void updateAll(GfxState *state)
108 updateFillColor(state);
109 updateStrokeColor(state);
110 updateLineWidth(state);
111 updateLineJoin(state);
112 updateLineCap(state);
115 //----- path painting
116 virtual void stroke(GfxState *state) ;
117 virtual void fill(GfxState *state) ;
118 virtual void eoFill(GfxState *state) ;
120 //----- path clipping
121 virtual void clip(GfxState *state) ;
122 virtual void eoClip(GfxState *state) ;
125 virtual GBool useTilingPatternFill();
126 virtual GBool useShadedFills();
129 virtual void tilingPatternFill(GfxState *state, Object *str,
130 int paintType, Dict *resDict,
131 double *mat, double *bbox,
132 int x0, int y0, int x1, int y1,
133 double xStep, double yStep) {}
134 virtual void functionShadedFill(GfxState *state,
135 GfxFunctionShading *shading) {}
136 virtual void axialShadedFill(GfxState *state, GfxAxialShading *shading) {}
137 virtual void radialShadedFill(GfxState *state, GfxRadialShading *shading) {}
141 virtual void beginString(GfxState *state, GString *s) ;
142 virtual void endString(GfxState *state) ;
143 virtual void endTextObject(GfxState *state);
144 virtual void drawChar(GfxState *state, double x, double y,
145 double dx, double dy,
146 double originX, double originY,
147 CharCode code, int nBytes, Unicode *u, int uLen);
149 //----- image drawing
150 virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
151 int width, int height, GBool invert,
153 virtual void drawImage(GfxState *state, Object *ref, Stream *str,
154 int width, int height, GfxImageColorMap *colorMap,
155 int *maskColors, GBool inlineImg);
156 virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
157 int width, int height,
158 GfxImageColorMap *colorMap,
159 Stream *maskStr, int maskWidth, int maskHeight,
161 virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
162 int width, int height,
163 GfxImageColorMap *colorMap,
165 int maskWidth, int maskHeight,
166 GfxImageColorMap *maskColorMap);
168 //----- transparency groups and soft masks (xpdf >= ~ 3.01.16)
169 #if xpdfUpdateVersion >= 16
170 virtual void beginTransparencyGroup(GfxState *state, double *bbox,
171 GfxColorSpace *blendingColorSpace,
172 GBool isolated, GBool knockout,
174 virtual void endTransparencyGroup(GfxState *state);
175 virtual void paintTransparencyGroup(GfxState *state, double *bbox);
176 virtual void setSoftMask(GfxState *state, double *bbox, GBool alpha, Function *transferFunc, GfxColor *backdropColor);
177 virtual void clearSoftMask(GfxState *state);
179 virtual void clearSoftMask(GfxState *state) {};
183 virtual GBool beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, Unicode *u, int uLen);
184 virtual void endType3Char(GfxState *state);
186 virtual void type3D0(GfxState *state, double wx, double wy);
187 virtual void type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury);
189 void preparePage(int pdfpage, int outputpage);
191 char* searchForSuitableFont(GfxFont*gfxFont);
196 void drawGeneralImage(GfxState *state, Object *ref, Stream *str,
197 int width, int height, GfxImageColorMap*colorMap, GBool invert,
198 GBool inlineImg, int mask, int *maskColors,
199 Stream *maskStr, int maskWidth, int maskHeight, GBool maskInvert, GfxImageColorMap*maskColorMap);
200 int setGfxFont(char*id, char*name, char*filename, double quality);
201 void strokeGfxline(GfxState *state, gfxline_t*line);
202 void clipToGfxLine(GfxState *state, gfxline_t*line);
203 void fillGfxLine(GfxState *state, gfxline_t*line);
205 char outer_clip_box; //whether the page clip box is still on
208 GFXOutputState states[64];
216 char* searchFont(char*name);
217 char* substituteFont(GfxFont*gfxFont, char*oldname);
218 char* writeEmbeddedFontToFile(XRef*ref, GfxFont*font);
220 int textmodeinfo; // did we write "Text will be rendered as polygon" yet?
221 int jpeginfo; // did we write "File contains jpegs" yet?
222 int pbminfo; // did we write "File contains jpegs" yet?
223 int linkinfo; // did we write "File contains links" yet?
225 int type3active; // are we between beginType3()/endType3()?
231 char* substitutetarget[256];
232 char* substitutesource[256];
235 int user_movex,user_movey;
236 int user_clipx1,user_clipx2,user_clipy1,user_clipy2;
238 /* upper left corner of clipping rectangle (cropbox)- needs to be
239 added to all drawing coordinates to give the impression that all
240 pages start at (0,0)*/
246 gfxline_t* current_text_stroke;
247 gfxline_t* current_text_clip;
248 char* current_font_id;
249 gfxfont_t* current_gfxfont;
250 gfxmatrix_t current_font_matrix;
252 fontlist_t* fontlist;
260 int config_use_fontconfig;
262 parameter_t*parameters;
265 #endif //__gfxoutputdev_h__