1 //========================================================================
5 // Copyright 1996 Derek B. Noonburg
7 //========================================================================
19 #include "OutputDev.h"
24 //------------------------------------------------------------------------
26 //------------------------------------------------------------------------
28 // Generate Level 1 PostScript?
29 extern GBool psOutLevel1;
32 extern int paperWidth;
33 extern int paperHeight;
35 //------------------------------------------------------------------------
37 //------------------------------------------------------------------------
40 psFile, // write to file
41 psPipe, // write to pipe
42 psStdout // write to stdout
45 class PSOutputDev: public OutputDev {
48 // Open a PostScript output file, and write the prolog.
49 PSOutputDev(char *fileName, Catalog *catalog,
50 int firstPage, int lastPage,
51 GBool embedType11, GBool doForm1);
53 // Destructor -- writes the trailer and closes the file.
54 virtual ~PSOutputDev();
56 // Check if file was successfully created.
57 virtual GBool isOk() { return ok; }
59 //---- get info about output device
61 // Does this device use upside-down coordinates?
62 // (Upside-down means (0,0) is the top left corner of the page.)
63 virtual GBool upsideDown() { return gFalse; }
65 // Does this device use drawChar() or drawString()?
66 virtual GBool useDrawChar() { return gFalse; }
68 //----- initialization and control
71 virtual void startPage(int pageNum, GfxState *state);
74 virtual void endPage();
76 //----- save/restore graphics state
77 virtual void saveState(GfxState *state);
78 virtual void restoreState(GfxState *state);
80 //----- update graphics state
81 virtual void updateCTM(GfxState *state, double m11, double m12,
82 double m21, double m22, double m31, double m32);
83 virtual void updateLineDash(GfxState *state);
84 virtual void updateFlatness(GfxState *state);
85 virtual void updateLineJoin(GfxState *state);
86 virtual void updateLineCap(GfxState *state);
87 virtual void updateMiterLimit(GfxState *state);
88 virtual void updateLineWidth(GfxState *state);
89 virtual void updateFillColor(GfxState *state);
90 virtual void updateStrokeColor(GfxState *state);
92 //----- update text state
93 virtual void updateFont(GfxState *state);
94 virtual void updateTextMat(GfxState *state);
95 virtual void updateCharSpace(GfxState *state);
96 virtual void updateRender(GfxState *state);
97 virtual void updateRise(GfxState *state);
98 virtual void updateWordSpace(GfxState *state);
99 virtual void updateHorizScaling(GfxState *state);
100 virtual void updateTextPos(GfxState *state);
101 virtual void updateTextShift(GfxState *state, double shift);
103 //----- path painting
104 virtual void stroke(GfxState *state);
105 virtual void fill(GfxState *state);
106 virtual void eoFill(GfxState *state);
108 //----- path clipping
109 virtual void clip(GfxState *state);
110 virtual void eoClip(GfxState *state);
113 virtual void drawString(GfxState *state, GString *s);
115 //----- image drawing
116 virtual void drawImageMask(GfxState *state, Stream *str,
117 int width, int height, GBool invert,
119 virtual void drawImage(GfxState *state, Stream *str, int width,
120 int height, GfxImageColorMap *colorMap,
125 void setupFonts(Dict *resDict);
126 void setupFont(GfxFont *font);
127 void setupEmbeddedType1Font(Ref *id);
128 void setupEmbeddedType1Font(char *fileName);
129 void setupEmbeddedType1CFont(GfxFont *font, Ref *id);
130 void doPath(GfxPath *path);
131 void doImageL1(GfxImageColorMap *colorMap,
132 GBool invert, GBool inlineImg,
133 Stream *str, int width, int height, int len);
134 void doImage(GfxImageColorMap *colorMap,
135 GBool invert, GBool inlineImg,
136 Stream *str, int width, int height, int len);
137 void writePS(char *fmt, ...);
138 void writePSString(GString *s);
140 GBool embedType1; // embed Type 1 fonts?
141 GBool doForm; // generate a form?
143 FILE *f; // PostScript file
144 PSFileType fileType; // file / pipe / stdout
145 int seqPage; // current sequential page number
147 Ref *fontIDs; // list of object IDs of all used fonts
148 int fontIDLen; // number of entries in fontIDs array
149 int fontIDSize; // size of fontIDs array
150 Ref *fontFileIDs; // list of object IDs of all embedded fonts
151 int fontFileIDLen; // number of entries in fontFileIDs array
152 int fontFileIDSize; // size of fontFileIDs array
153 char **fontFileNames; // list of names of all embedded external fonts
154 int fontFileNameLen; // number of entries in fontFileNames array
155 int fontFileNameSize; // size of fontFileNames array
157 GBool ok; // set up ok?