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;
26 typedef struct _parameter
30 struct _parameter*next;
33 void addGlobalFont(char*filename);
34 void addGlobalLanguageDir(char*dir);
35 void addGlobalFontDir(char*dirname);
37 class GFXOutputDev: public OutputDev {
42 GFXOutputDev(parameter_t*p);
43 void setDevice(gfxdevice_t*dev);
46 virtual ~GFXOutputDev() ;
48 void setMove(int x,int y);
49 void setClip(int x1,int y1,int x2,int y2);
51 void setInfo(InfoOutputDev*info) {this->info = info;}
54 void startFrame(int width, int height);
56 virtual void startPage(int pageNum, GfxState *state, double x1, double y1, double x2, double y2) ;
60 //----- get info about output device
62 // Does this device use upside-down coordinates?
63 // (Upside-down means (0,0) is the top left corner of the page.)
64 virtual GBool upsideDown();
66 // Does this device use drawChar() or drawString()?
67 virtual GBool useDrawChar();
69 virtual GBool interpretType3Chars();
71 //virtual GBool useShadedFills() { return gTrue; }
73 //----- initialization and control
75 void setXRef(PDFDoc*doc, XRef *xref);
78 virtual void drawLink(Link *link, Catalog *catalog) ;
80 //----- save/restore graphics state
81 virtual void saveState(GfxState *state) ;
82 virtual void restoreState(GfxState *state) ;
84 //----- update graphics state
86 virtual void updateFont(GfxState *state);
87 virtual void updateFillColor(GfxState *state);
88 virtual void updateStrokeColor(GfxState *state);
89 virtual void updateLineWidth(GfxState *state);
90 virtual void updateLineJoin(GfxState *state);
91 virtual void updateLineCap(GfxState *state);
92 virtual void updateFillOpacity(GfxState *state);
95 virtual void updateAll(GfxState *state)
98 updateFillColor(state);
99 updateStrokeColor(state);
100 updateLineWidth(state);
101 updateLineJoin(state);
102 updateLineCap(state);
105 //----- path painting
106 virtual void stroke(GfxState *state) ;
107 virtual void fill(GfxState *state) ;
108 virtual void eoFill(GfxState *state) ;
110 //----- path clipping
111 virtual void clip(GfxState *state) ;
112 virtual void eoClip(GfxState *state) ;
115 virtual void beginString(GfxState *state, GString *s) ;
116 virtual void endString(GfxState *state) ;
117 virtual void endTextObject(GfxState *state);
118 virtual void drawChar(GfxState *state, double x, double y,
119 double dx, double dy,
120 double originX, double originY,
121 CharCode code, int nBytes, Unicode *u, int uLen);
123 //----- image drawing
124 virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
125 int width, int height, GBool invert,
127 virtual void drawImage(GfxState *state, Object *ref, Stream *str,
128 int width, int height, GfxImageColorMap *colorMap,
129 int *maskColors, GBool inlineImg);
130 virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
131 int width, int height,
132 GfxImageColorMap *colorMap,
133 Stream *maskStr, int maskWidth, int maskHeight,
135 virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
136 int width, int height,
137 GfxImageColorMap *colorMap,
139 int maskWidth, int maskHeight,
140 GfxImageColorMap *maskColorMap);
142 //----- transparency groups and soft masks (xpdf >= ~ 3.01.16)
143 #if xpdfUpdateVersion >= 16
144 virtual void beginTransparencyGroup(GfxState *state, double *bbox,
145 GfxColorSpace *blendingColorSpace,
146 GBool isolated, GBool knockout,
148 virtual void endTransparencyGroup(GfxState *state);
149 virtual void paintTransparencyGroup(GfxState *state, double *bbox);
150 virtual void setSoftMask(GfxState *state, double *bbox, GBool alpha, Function *transferFunc, GfxColor *backdropColor);
151 virtual void clearSoftMask(GfxState *state);
155 virtual GBool beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, Unicode *u, int uLen);
156 virtual void endType3Char(GfxState *state);
158 virtual void type3D0(GfxState *state, double wx, double wy);
159 virtual void type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury);
161 void preparePage(int pdfpage, int outputpage);
163 char* searchForSuitableFont(GfxFont*gfxFont);
168 void drawGeneralImage(GfxState *state, Object *ref, Stream *str,
169 int width, int height, GfxImageColorMap*colorMap, GBool invert,
170 GBool inlineImg, int mask, int *maskColors,
171 Stream *maskStr, int maskWidth, int maskHeight, GBool maskInvert, GfxImageColorMap*maskColorMap);
172 int setGfxFont(char*id, char*name, char*filename, double quality);
173 void strokeGfxline(GfxState *state, gfxline_t*line);
174 void clipToGfxLine(GfxState *state, gfxline_t*line);
175 void fillGfxLine(GfxState *state, gfxline_t*line);
177 char outer_clip_box; //whether the page clip box is still on
180 GFXOutputState states[64];
188 char* searchFont(char*name);
189 char* substituteFont(GfxFont*gfxFont, char*oldname);
190 char* writeEmbeddedFontToFile(XRef*ref, GfxFont*font);
192 int textmodeinfo; // did we write "Text will be rendered as polygon" yet?
193 int jpeginfo; // did we write "File contains jpegs" yet?
194 int pbminfo; // did we write "File contains jpegs" yet?
195 int linkinfo; // did we write "File contains links" yet?
196 int ttfinfo; // did we write "File contains TrueType Fonts" yet?
197 int gradientinfo; // did we write "File contains Gradients yet?
199 int type3active; // are we between beginType3()/endType3()?
205 char* substitutetarget[256];
206 char* substitutesource[256];
209 /* upper left corner of clipping rectangle (cropbox)- needs to be
210 added to all drawing coordinates to give the impression that all
211 pages start at (0,0)*/
212 int clipmovex,clipmovey;
214 int user_movex,user_movey;
215 int user_clipx1,user_clipx2,user_clipy1,user_clipy2;
217 gfxline_t* current_text_stroke;
218 gfxline_t* current_text_clip;
219 char* current_font_id;
220 gfxfont_t* current_gfxfont;
221 gfxmatrix_t current_font_matrix;
223 fontlist_t* fontlist;
231 int config_use_fontconfig;
233 parameter_t*parameters;
236 #endif //__gfxoutputdev_h__