filters

PSOutputDev.h

00001 //========================================================================
00002 //
00003 // PSOutputDev.h
00004 //
00005 // Copyright 1996-2002 Glyph & Cog, LLC
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 struct PSFont16Enc;
00029 class PSOutCustomColor;
00030 
00031 //------------------------------------------------------------------------
00032 // PSOutputDev
00033 //------------------------------------------------------------------------
00034 
00035 enum PSOutMode {
00036   psModePS,
00037   psModeEPS,
00038   psModeForm
00039 };
00040 
00041 enum PSFileType {
00042   psFile,           // write to file
00043   psPipe,           // write to pipe
00044   psStdout,         // write to stdout
00045   psGeneric         // write to a generic stream
00046 };
00047 
00048 typedef void (*PSOutputFunc)(void *stream, char *data, int len);
00049 
00050 class PSOutputDev: public OutputDev {
00051 public:
00052 
00053   // Open a PostScript output file, and write the prolog.
00054   PSOutputDev(char *fileName, XRef *xrefA, Catalog *catalog,
00055           int firstPage, int lastPage, PSOutMode modeA);
00056 
00057   // Open a PSOutputDev that will write to a generic stream.
00058   PSOutputDev(PSOutputFunc outputFuncA, void *outputStreamA,
00059           XRef *xrefA, Catalog *catalog,
00060           int firstPage, int lastPage, PSOutMode modeA);
00061 
00062   // Destructor -- writes the trailer and closes the file.
00063   virtual ~PSOutputDev();
00064 
00065   // Check if file was successfully created.
00066   virtual GBool isOk() { return ok; }
00067 
00068   //---- get info about output device
00069 
00070   // Does this device use upside-down coordinates?
00071   // (Upside-down means (0,0) is the top left corner of the page.)
00072   virtual GBool upsideDown() { return gFalse; }
00073 
00074   // Does this device use drawChar() or drawString()?
00075   virtual GBool useDrawChar() { return gFalse; }
00076 
00077   // Does this device use beginType3Char/endType3Char?  Otherwise,
00078   // text in Type 3 fonts will be drawn with drawChar/drawString.
00079   virtual GBool interpretType3Chars() { return gFalse; }
00080 
00081   //----- initialization and control
00082 
00083   // Start a page.
00084   virtual void startPage(int pageNum, GfxState *state);
00085 
00086   // End a page.
00087   virtual void endPage();
00088 
00089   //----- save/restore graphics state
00090   virtual void saveState(GfxState *state);
00091   virtual void restoreState(GfxState *state);
00092 
00093   //----- update graphics state
00094   virtual void updateCTM(GfxState *state, double m11, double m12,
00095              double m21, double m22, double m31, double m32);
00096   virtual void updateLineDash(GfxState *state);
00097   virtual void updateFlatness(GfxState *state);
00098   virtual void updateLineJoin(GfxState *state);
00099   virtual void updateLineCap(GfxState *state);
00100   virtual void updateMiterLimit(GfxState *state);
00101   virtual void updateLineWidth(GfxState *state);
00102   virtual void updateFillColor(GfxState *state);
00103   virtual void updateStrokeColor(GfxState *state);
00104 
00105   //----- update text state
00106   virtual void updateFont(GfxState *state);
00107   virtual void updateTextMat(GfxState *state);
00108   virtual void updateCharSpace(GfxState *state);
00109   virtual void updateRender(GfxState *state);
00110   virtual void updateRise(GfxState *state);
00111   virtual void updateWordSpace(GfxState *state);
00112   virtual void updateHorizScaling(GfxState *state);
00113   virtual void updateTextPos(GfxState *state);
00114   virtual void updateTextShift(GfxState *state, double shift);
00115 
00116   //----- path painting
00117   virtual void stroke(GfxState *state);
00118   virtual void fill(GfxState *state);
00119   virtual void eoFill(GfxState *state);
00120 
00121   //----- path clipping
00122   virtual void clip(GfxState *state);
00123   virtual void eoClip(GfxState *state);
00124 
00125   //----- text drawing
00126   virtual void drawString(GfxState *state, GString *s);
00127 
00128   //----- image drawing
00129   virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
00130                  int width, int height, GBool invert,
00131                  GBool inlineImg);
00132   virtual void drawImage(GfxState *state, Object *ref, Stream *str,
00133              int width, int height, GfxImageColorMap *colorMap,
00134              int *maskColors, GBool inlineImg);
00135 
00136 #if OPI_SUPPORT
00137   //----- OPI functions
00138   virtual void opiBegin(GfxState *state, Dict *opiDict);
00139   virtual void opiEnd(GfxState *state, Dict *opiDict);
00140 #endif
00141 
00142   //----- Type 3 font operators
00143   virtual void type3D0(GfxState *state, double wx, double wy);
00144   virtual void type3D1(GfxState *state, double wx, double wy,
00145                double llx, double lly, double urx, double ury);
00146 
00147   //----- PostScript XObjects
00148   virtual void psXObject(Stream *psStream, Stream *level1Stream);
00149 
00150 
00151 private:
00152 
00153   void init(PSOutputFunc outputFuncA, void *outputStreamA,
00154         PSFileType fileTypeA, XRef *xrefA, Catalog *catalog,
00155         int firstPage, int lastPage, PSOutMode modeA);
00156   void setupResources(Dict *resDict);
00157   void setupFonts(Dict *resDict);
00158   void setupFont(GfxFont *font, Dict *parentResDict);
00159   void setupEmbeddedType1Font(Ref *id, char *psName);
00160   void setupExternalType1Font(GString *fileName, char *psName);
00161   void setupEmbeddedType1CFont(GfxFont *font, Ref *id, char *psName);
00162   void setupEmbeddedTrueTypeFont(GfxFont *font, Ref *id, char *psName);
00163   void setupExternalTrueTypeFont(GfxFont *font, char *psName);
00164   void setupEmbeddedCIDType0Font(GfxFont *font, Ref *id, char *psName);
00165   void setupEmbeddedCIDTrueTypeFont(GfxFont *font, Ref *id, char *psName);
00166   void setupType3Font(GfxFont *font, char *psName, Dict *parentResDict);
00167   void setupImages(Dict *resDict);
00168   void setupImage(Ref id, Stream *str);
00169   void addProcessColor(double c, double m, double y, double k);
00170   void addCustomColor(GfxSeparationColorSpace *sepCS);
00171   void doPath(GfxPath *path);
00172   void doImageL1(GfxImageColorMap *colorMap,
00173          GBool invert, GBool inlineImg,
00174          Stream *str, int width, int height, int len);
00175   void doImageL1Sep(GfxImageColorMap *colorMap,
00176             GBool invert, GBool inlineImg,
00177             Stream *str, int width, int height, int len);
00178   void doImageL2(Object *ref, GfxImageColorMap *colorMap,
00179          GBool invert, GBool inlineImg,
00180          Stream *str, int width, int height, int len);
00181   void dumpColorSpaceL2(GfxColorSpace *colorSpace);
00182 #if OPI_SUPPORT
00183   void opiBegin20(GfxState *state, Dict *dict);
00184   void opiBegin13(GfxState *state, Dict *dict);
00185   void opiTransform(GfxState *state, double x0, double y0,
00186             double *x1, double *y1);
00187   GBool getFileSpec(Object *fileSpec, Object *fileName);
00188 #endif
00189   void writePSChar(char c);
00190   void writePS(char *s);
00191   void writePSFmt(const char *fmt, ...);
00192   void writePSString(GString *s);
00193   void writePSName(char *s);
00194   GString *filterPSName(GString *name);
00195 
00196   PSLevel level;        // PostScript level (1, 2, separation)
00197   PSOutMode mode;       // PostScript mode (PS, EPS, form)
00198   int paperWidth;       // width of paper, in pts
00199   int paperHeight;      // height of paper, in pts
00200 
00201   PSOutputFunc outputFunc;
00202   void *outputStream;
00203   PSFileType fileType;      // file / pipe / stdout
00204   int seqPage;          // current sequential page number
00205 
00206   XRef *xref;           // the xref table for this PDF file
00207 
00208   Ref *fontIDs;         // list of object IDs of all used fonts
00209   int fontIDLen;        // number of entries in fontIDs array
00210   int fontIDSize;       // size of fontIDs array
00211   Ref *fontFileIDs;     // list of object IDs of all embedded fonts
00212   int fontFileIDLen;        // number of entries in fontFileIDs array
00213   int fontFileIDSize;       // size of fontFileIDs array
00214   GString **fontFileNames;  // list of names of all embedded external fonts
00215   int fontFileNameLen;      // number of entries in fontFileNames array
00216   int fontFileNameSize;     // size of fontFileNames array
00217   PSFont16Enc *font16Enc;   // encodings for substitute 16-bit fonts
00218   int font16EncLen;     // number of entries in font16Enc array
00219   int font16EncSize;        // size of font16Enc array
00220 
00221   double tx, ty;        // global translation
00222   double xScale, yScale;    // global scaling
00223   GBool landscape;      // true for landscape, false for portrait
00224 
00225   GString *embFontList;     // resource comments for embedded fonts
00226 
00227   int processColors;        // used process colors
00228   PSOutCustomColor      // used custom colors
00229     *customColors;
00230 
00231   GBool inType3Char;        // inside a Type 3 CharProc
00232   GString *t3String;        // Type 3 content string
00233   double t3WX, t3WY,        // Type 3 character parameters
00234          t3LLX, t3LLY, t3URX, t3URY;
00235   GBool t3Cacheable;        // cleared if char is not cacheable
00236 
00237 #if OPI_SUPPORT
00238   int opi13Nest;        // nesting level of OPI 1.3 objects
00239   int opi20Nest;        // nesting level of OPI 2.0 objects
00240 #endif
00241 
00242   GBool ok;         // set up ok?
00243 
00244 };
00245 
00246 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys