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 void beginString(GfxState *state, GString *s) ;
126 virtual void endString(GfxState *state) ;
127 virtual void endTextObject(GfxState *state);
128 virtual void drawChar(GfxState *state, double x, double y,
129 double dx, double dy,
130 double originX, double originY,
131 CharCode code, int nBytes, Unicode *u, int uLen);
133 //----- image drawing
134 virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
135 int width, int height, GBool invert,
137 virtual void drawImage(GfxState *state, Object *ref, Stream *str,
138 int width, int height, GfxImageColorMap *colorMap,
139 int *maskColors, GBool inlineImg);
140 virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
141 int width, int height,
142 GfxImageColorMap *colorMap,
143 Stream *maskStr, int maskWidth, int maskHeight,
145 virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
146 int width, int height,
147 GfxImageColorMap *colorMap,
149 int maskWidth, int maskHeight,
150 GfxImageColorMap *maskColorMap);
152 //----- transparency groups and soft masks (xpdf >= ~ 3.01.16)
153 #if xpdfUpdateVersion >= 16
154 virtual void beginTransparencyGroup(GfxState *state, double *bbox,
155 GfxColorSpace *blendingColorSpace,
156 GBool isolated, GBool knockout,
158 virtual void endTransparencyGroup(GfxState *state);
159 virtual void paintTransparencyGroup(GfxState *state, double *bbox);
160 virtual void setSoftMask(GfxState *state, double *bbox, GBool alpha, Function *transferFunc, GfxColor *backdropColor);
161 virtual void clearSoftMask(GfxState *state);
165 virtual GBool beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, Unicode *u, int uLen);
166 virtual void endType3Char(GfxState *state);
168 virtual void type3D0(GfxState *state, double wx, double wy);
169 virtual void type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury);
171 void preparePage(int pdfpage, int outputpage);
173 char* searchForSuitableFont(GfxFont*gfxFont);
178 void drawGeneralImage(GfxState *state, Object *ref, Stream *str,
179 int width, int height, GfxImageColorMap*colorMap, GBool invert,
180 GBool inlineImg, int mask, int *maskColors,
181 Stream *maskStr, int maskWidth, int maskHeight, GBool maskInvert, GfxImageColorMap*maskColorMap);
182 int setGfxFont(char*id, char*name, char*filename, double quality);
183 void strokeGfxline(GfxState *state, gfxline_t*line);
184 void clipToGfxLine(GfxState *state, gfxline_t*line);
185 void fillGfxLine(GfxState *state, gfxline_t*line);
187 char outer_clip_box; //whether the page clip box is still on
190 GFXOutputState states[64];
198 char* searchFont(char*name);
199 char* substituteFont(GfxFont*gfxFont, char*oldname);
200 char* writeEmbeddedFontToFile(XRef*ref, GfxFont*font);
202 int textmodeinfo; // did we write "Text will be rendered as polygon" yet?
203 int jpeginfo; // did we write "File contains jpegs" yet?
204 int pbminfo; // did we write "File contains jpegs" yet?
205 int linkinfo; // did we write "File contains links" yet?
206 int ttfinfo; // did we write "File contains TrueType Fonts" yet?
207 int gradientinfo; // did we write "File contains Gradients yet?
209 int type3active; // are we between beginType3()/endType3()?
215 char* substitutetarget[256];
216 char* substitutesource[256];
219 int user_movex,user_movey;
220 int user_clipx1,user_clipx2,user_clipy1,user_clipy2;
222 /* upper left corner of clipping rectangle (cropbox)- needs to be
223 added to all drawing coordinates to give the impression that all
224 pages start at (0,0)*/
230 gfxline_t* current_text_stroke;
231 gfxline_t* current_text_clip;
232 char* current_font_id;
233 gfxfont_t* current_gfxfont;
234 gfxmatrix_t current_font_matrix;
236 fontlist_t* fontlist;
244 int config_use_fontconfig;
246 parameter_t*parameters;
249 #endif //__gfxoutputdev_h__