00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef PSOUTPUTDEV_H
00010 #define PSOUTPUTDEV_H
00011
00012 #include <aconf.h>
00013
00014 #ifdef USE_GCC_PRAGMAS
00015 #pragma interface
00016 #endif
00017
00018 #include <stddef.h>
00019 #include "config.h"
00020 #include "Object.h"
00021 #include "GlobalParams.h"
00022 #include "OutputDev.h"
00023
00024 class GfxPath;
00025 class GfxFont;
00026 class GfxColorSpace;
00027 class GfxSeparationColorSpace;
00028 class PDFRectangle;
00029 struct PSFont16Enc;
00030 class PSOutCustomColor;
00031
00032
00033
00034
00035
00036 enum PSOutMode {
00037 psModePS,
00038 psModeEPS,
00039 psModeForm
00040 };
00041
00042 enum PSFileType {
00043 psFile,
00044 psPipe,
00045 psStdout,
00046 psGeneric
00047 };
00048
00049 typedef void (*PSOutputFunc)(void *stream, char *data, int len);
00050
00051 class PSOutputDev: public OutputDev {
00052 public:
00053
00054
00055 PSOutputDev(char *fileName, XRef *xrefA, Catalog *catalog,
00056 int firstPage, int lastPage, PSOutMode modeA,
00057 int imgLLXA = 0, int imgLLYA = 0,
00058 int imgURXA = 0, int imgURYA = 0,
00059 GBool manualCtrlA = gFalse);
00060
00061
00062 PSOutputDev(PSOutputFunc outputFuncA, void *outputStreamA,
00063 XRef *xrefA, Catalog *catalog,
00064 int firstPage, int lastPage, PSOutMode modeA,
00065 int imgLLXA = 0, int imgLLYA = 0,
00066 int imgURXA = 0, int imgURYA = 0,
00067 GBool manualCtrlA = gFalse);
00068
00069
00070 virtual ~PSOutputDev();
00071
00072
00073 virtual GBool isOk() { return ok; }
00074
00075
00076
00077
00078
00079 virtual GBool upsideDown() { return gFalse; }
00080
00081
00082 virtual GBool useDrawChar() { return gFalse; }
00083
00084
00085
00086 virtual GBool interpretType3Chars() { return gFalse; }
00087
00088
00089
00090
00091 void writeHeader(int firstPage, int lastPage,
00092 PDFRectangle *mediaBox, PDFRectangle *cropBox);
00093
00094
00095 void writeXpdfProcset();
00096
00097
00098 void writeDocSetup(Catalog *catalog, int firstPage, int lastPage);
00099
00100
00101 void writePageSetup();
00102
00103
00104 void writePageTrailer();
00105
00106
00107 void writeTrailer();
00108
00109
00110
00111
00112 virtual void startPage(int pageNum, GfxState *state);
00113
00114
00115 virtual void endPage();
00116
00117
00118 virtual void saveState(GfxState *state);
00119 virtual void restoreState(GfxState *state);
00120
00121
00122 virtual void updateCTM(GfxState *state, double m11, double m12,
00123 double m21, double m22, double m31, double m32);
00124 virtual void updateLineDash(GfxState *state);
00125 virtual void updateFlatness(GfxState *state);
00126 virtual void updateLineJoin(GfxState *state);
00127 virtual void updateLineCap(GfxState *state);
00128 virtual void updateMiterLimit(GfxState *state);
00129 virtual void updateLineWidth(GfxState *state);
00130 virtual void updateFillColor(GfxState *state);
00131 virtual void updateStrokeColor(GfxState *state);
00132
00133
00134 virtual void updateFont(GfxState *state);
00135 virtual void updateTextMat(GfxState *state);
00136 virtual void updateCharSpace(GfxState *state);
00137 virtual void updateRender(GfxState *state);
00138 virtual void updateRise(GfxState *state);
00139 virtual void updateWordSpace(GfxState *state);
00140 virtual void updateHorizScaling(GfxState *state);
00141 virtual void updateTextPos(GfxState *state);
00142 virtual void updateTextShift(GfxState *state, double shift);
00143
00144
00145 virtual void stroke(GfxState *state);
00146 virtual void fill(GfxState *state);
00147 virtual void eoFill(GfxState *state);
00148
00149
00150 virtual void clip(GfxState *state);
00151 virtual void eoClip(GfxState *state);
00152
00153
00154 virtual void drawString(GfxState *state, GString *s);
00155 virtual void endTextObject(GfxState *state);
00156
00157
00158 virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
00159 int width, int height, GBool invert,
00160 GBool inlineImg);
00161 virtual void drawImage(GfxState *state, Object *ref, Stream *str,
00162 int width, int height, GfxImageColorMap *colorMap,
00163 int *maskColors, GBool inlineImg);
00164
00165 #if OPI_SUPPORT
00166
00167 virtual void opiBegin(GfxState *state, Dict *opiDict);
00168 virtual void opiEnd(GfxState *state, Dict *opiDict);
00169 #endif
00170
00171
00172 virtual void type3D0(GfxState *state, double wx, double wy);
00173 virtual void type3D1(GfxState *state, double wx, double wy,
00174 double llx, double lly, double urx, double ury);
00175
00176
00177 virtual void psXObject(Stream *psStream, Stream *level1Stream);
00178
00179
00180 void setOffset(double x, double y)
00181 { tx0 = x; ty0 = y; }
00182 void setScale(double x, double y)
00183 { xScale0 = x; yScale0 = y; }
00184 void setRotate(int rotateA)
00185 { rotate0 = rotateA; }
00186 void setClip(double llx, double lly, double urx, double ury)
00187 { clipLLX0 = llx; clipLLY0 = lly; clipURX0 = urx; clipURY0 = ury; }
00188 void setUnderlayCbk(void (*cbk)(PSOutputDev *psOut, void *data),
00189 void *data)
00190 { underlayCbk = cbk; underlayCbkData = data; }
00191 void setOverlayCbk(void (*cbk)(PSOutputDev *psOut, void *data),
00192 void *data)
00193 { overlayCbk = cbk; overlayCbkData = data; }
00194
00195 private:
00196
00197 void init(PSOutputFunc outputFuncA, void *outputStreamA,
00198 PSFileType fileTypeA, XRef *xrefA, Catalog *catalog,
00199 int firstPage, int lastPage, PSOutMode modeA,
00200 int imgLLXA, int imgLLYA, int imgURXA, int imgURYA,
00201 GBool manualCtrlA);
00202 void setupResources(Dict *resDict);
00203 void setupFonts(Dict *resDict);
00204 void setupFont(GfxFont *font, Dict *parentResDict);
00205 void setupEmbeddedType1Font(Ref *id, GString *psName);
00206 void setupExternalType1Font(GString *fileName, GString *psName);
00207 void setupEmbeddedType1CFont(GfxFont *font, Ref *id, GString *psName);
00208 void setupEmbeddedTrueTypeFont(GfxFont *font, Ref *id, GString *psName);
00209 void setupExternalTrueTypeFont(GfxFont *font, GString *psName);
00210 void setupEmbeddedCIDType0Font(GfxFont *font, Ref *id, GString *psName);
00211 void setupEmbeddedCIDTrueTypeFont(GfxFont *font, Ref *id, GString *psName);
00212 void setupType3Font(GfxFont *font, GString *psName, Dict *parentResDict);
00213 void setupImages(Dict *resDict);
00214 void setupImage(Ref id, Stream *str);
00215 void addProcessColor(double c, double m, double y, double k);
00216 void addCustomColor(GfxSeparationColorSpace *sepCS);
00217 void doPath(GfxPath *path);
00218 void doImageL1(Object *ref, GfxImageColorMap *colorMap,
00219 GBool invert, GBool inlineImg,
00220 Stream *str, int width, int height, int len);
00221 void doImageL1Sep(GfxImageColorMap *colorMap,
00222 GBool invert, GBool inlineImg,
00223 Stream *str, int width, int height, int len);
00224 void doImageL2(Object *ref, GfxImageColorMap *colorMap,
00225 GBool invert, GBool inlineImg,
00226 Stream *str, int width, int height, int len);
00227 void dumpColorSpaceL2(GfxColorSpace *colorSpace);
00228 #if OPI_SUPPORT
00229 void opiBegin20(GfxState *state, Dict *dict);
00230 void opiBegin13(GfxState *state, Dict *dict);
00231 void opiTransform(GfxState *state, double x0, double y0,
00232 double *x1, double *y1);
00233 GBool getFileSpec(Object *fileSpec, Object *fileName);
00234 #endif
00235 void writePSChar(char c);
00236 void writePS(char *s);
00237 void writePSFmt(const char *fmt, ...);
00238 void writePSString(GString *s);
00239 void writePSName(char *s);
00240 GString *filterPSName(GString *name);
00241
00242 PSLevel level;
00243 PSOutMode mode;
00244 int paperWidth;
00245 int paperHeight;
00246 int imgLLX, imgLLY,
00247 imgURX, imgURY;
00248
00249 PSOutputFunc outputFunc;
00250 void *outputStream;
00251 PSFileType fileType;
00252 GBool manualCtrl;
00253 int seqPage;
00254 void (*underlayCbk)(PSOutputDev *psOut, void *data);
00255 void *underlayCbkData;
00256 void (*overlayCbk)(PSOutputDev *psOut, void *data);
00257 void *overlayCbkData;
00258
00259 XRef *xref;
00260
00261 Ref *fontIDs;
00262 int fontIDLen;
00263 int fontIDSize;
00264 Ref *fontFileIDs;
00265 int fontFileIDLen;
00266 int fontFileIDSize;
00267 GString **fontFileNames;
00268 int fontFileNameLen;
00269 int fontFileNameSize;
00270 int nextTrueTypeNum;
00271
00272 PSFont16Enc *font16Enc;
00273 int font16EncLen;
00274 int font16EncSize;
00275 GList *xobjStack;
00276
00277 int numSaves;
00278
00279 double tx0, ty0;
00280 double xScale0, yScale0;
00281 int rotate0;
00282 double clipLLX0, clipLLY0,
00283 clipURX0, clipURY0;
00284 double tx, ty;
00285 double xScale, yScale;
00286 int rotate;
00287
00288 GString *embFontList;
00289
00290 int processColors;
00291 PSOutCustomColor
00292 *customColors;
00293
00294 GBool haveTextClip;
00295
00296
00297 GBool inType3Char;
00298 GString *t3String;
00299 double t3WX, t3WY,
00300 t3LLX, t3LLY, t3URX, t3URY;
00301 GBool t3Cacheable;
00302
00303 #if OPI_SUPPORT
00304 int opi13Nest;
00305 int opi20Nest;
00306 #endif
00307
00308 GBool ok;
00309
00310
00311 friend class WinPDFPrinter;
00312 };
00313
00314 #endif