1 //======================================================================== 2 // 3 // PSOutputDev.h 4 // 5 // Copyright 1996-2003 Glyph & Cog, LLC 6 // 7 //======================================================================== 8 9 //======================================================================== 10 // 11 // Modified under the Poppler project - http://poppler.freedesktop.org 12 // 13 // All changes made under the Poppler project to this file are licensed 14 // under GPL version 2 or later 15 // 16 // Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> 17 // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com> 18 // Copyright (C) 2006-2008, 2012, 2013, 2015, 2017-2021 Albert Astals Cid <aacid@kde.org> 19 // Copyright (C) 2007 Brad Hards <bradh@kde.org> 20 // Copyright (C) 2009-2013 Thomas Freitag <Thomas.Freitag@alfa.de> 21 // Copyright (C) 2009 Till Kamppeter <till.kamppeter@gmail.com> 22 // Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org> 23 // Copyright (C) 2009, 2011, 2015-2017, 2020 William Bader <williambader@hotmail.com> 24 // Copyright (C) 2010 Hib Eris <hib@hiberis.nl> 25 // Copyright (C) 2011, 2014, 2017, 2020 Adrian Johnson <ajohnson@redneon.com> 26 // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> 27 // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich 28 // Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de> 29 // Copyright (C) 2018, 2020 Philipp Knechtges <philipp-dev@knechtges.com> 30 // Copyright (C) 2019 Oliver Sander <oliver.sander@tu-dresden.de> 31 // Copyright (C) 2021 Hubert Figuiere <hub@figuiere.net> 32 // Copyright (C) 2021 Christian Persch <chpe@src.gnome.org> 33 // 34 // To see a description of the changes please see the Changelog file that 35 // came with your tarball or type make ChangeLog if you are building from git 36 // 37 //======================================================================== 38 39 #ifndef PSOUTPUTDEV_H 40 #define PSOUTPUTDEV_H 41 42 #include "poppler-config.h" 43 #include "poppler_private_export.h" 44 #include <cstddef> 45 #include "Object.h" 46 #include "GfxState.h" 47 #include "GlobalParams.h" 48 #include "OutputDev.h" 49 #include <set> 50 #include <map> 51 #include <vector> 52 #include <unordered_set> 53 #include <unordered_map> 54 #include <string> 55 56 #include "splash/Splash.h" 57 58 class PDFDoc; 59 class XRef; 60 class Function; 61 class GfxPath; 62 class GfxFont; 63 class GfxColorSpace; 64 class GfxSeparationColorSpace; 65 class PDFRectangle; 66 struct PST1FontName; 67 struct PSFont8Info; 68 struct PSFont16Enc; 69 class PSOutCustomColor; 70 struct PSOutPaperSize; 71 class PSOutputDev; 72 73 //------------------------------------------------------------------------ 74 // PSOutputDev 75 //------------------------------------------------------------------------ 76 77 enum PSLevel 78 { 79 psLevel1, 80 psLevel1Sep, 81 psLevel2, 82 psLevel2Sep, 83 psLevel3, 84 psLevel3Sep 85 }; 86 87 enum PSOutMode 88 { 89 psModePS, 90 psModeEPS, 91 psModeForm 92 }; 93 94 enum PSFileType 95 { 96 psFile, // write to file 97 psPipe, // write to pipe 98 psStdout, // write to stdout 99 psGeneric // write to a generic stream 100 }; 101 102 enum PSOutCustomCodeLocation 103 { 104 psOutCustomDocSetup, 105 psOutCustomPageSetup 106 }; 107 108 enum PSForceRasterize 109 { 110 psRasterizeWhenNeeded, // default 111 psAlwaysRasterize, // always rasterize, useful for testing 112 psNeverRasterize // never rasterize, may produce incorrect output 113 }; 114 115 typedef void (*PSOutputFunc)(void *stream, const char *data, int len); 116 117 typedef GooString *(*PSOutCustomCodeCbk)(PSOutputDev *psOut, PSOutCustomCodeLocation loc, int n, void *data); 118 119 class POPPLER_PRIVATE_EXPORT PSOutputDev : public OutputDev 120 { 121 public: 122 // Open a PostScript output file, and write the prolog. 123 // pages has to be sorted in increasing order 124 PSOutputDev(const char *fileName, PDFDoc *docA, char *psTitleA, const std::vector<int> &pages, PSOutMode modeA, int paperWidthA = -1, int paperHeightA = -1, bool noCrop = false, bool duplexA = true, int imgLLXA = 0, int imgLLYA = 0, 125 int imgURXA = 0, int imgURYA = 0, PSForceRasterize forceRasterizeA = psRasterizeWhenNeeded, bool manualCtrlA = false, PSOutCustomCodeCbk customCodeCbkA = nullptr, void *customCodeCbkDataA = nullptr, 126 PSLevel levelA = psLevel2); 127 128 // Open a PSOutputDev that will write to a file descriptor 129 PSOutputDev(int fdA, PDFDoc *docA, char *psTitleA, const std::vector<int> &pages, PSOutMode modeA, int paperWidthA = -1, int paperHeightA = -1, bool noCrop = false, bool duplexA = true, int imgLLXA = 0, int imgLLYA = 0, int imgURXA = 0, 130 int imgURYA = 0, PSForceRasterize forceRasterizeA = psRasterizeWhenNeeded, bool manualCtrlA = false, PSOutCustomCodeCbk customCodeCbkA = nullptr, void *customCodeCbkDataA = nullptr, PSLevel levelA = psLevel2); 131 132 // Open a PSOutputDev that will write to a generic stream. 133 // pages has to be sorted in increasing order 134 PSOutputDev(PSOutputFunc outputFuncA, void *outputStreamA, char *psTitleA, PDFDoc *docA, const std::vector<int> &pages, PSOutMode modeA, int paperWidthA = -1, int paperHeightA = -1, bool noCrop = false, bool duplexA = true, 135 int imgLLXA = 0, int imgLLYA = 0, int imgURXA = 0, int imgURYA = 0, PSForceRasterize forceRasterizeA = psRasterizeWhenNeeded, bool manualCtrlA = false, PSOutCustomCodeCbk customCodeCbkA = nullptr, 136 void *customCodeCbkDataA = nullptr, PSLevel levelA = psLevel2); 137 138 // Destructor -- writes the trailer and closes the file. 139 ~PSOutputDev() override; 140 141 // Check if file was successfully created. isOk()142 virtual bool isOk() { return ok; } 143 144 //---- get info about output device 145 146 // Does this device use upside-down coordinates? 147 // (Upside-down means (0,0) is the top left corner of the page.) upsideDown()148 bool upsideDown() override { return false; } 149 150 // Does this device use drawChar() or drawString()? useDrawChar()151 bool useDrawChar() override { return false; } 152 153 // Does this device use tilingPatternFill()? If this returns false, 154 // tiling pattern fills will be reduced to a series of other drawing 155 // operations. useTilingPatternFill()156 bool useTilingPatternFill() override { return true; } 157 158 // Does this device use functionShadedFill(), axialShadedFill(), and 159 // radialShadedFill()? If this returns false, these shaded fills 160 // will be reduced to a series of other drawing operations. useShadedFills(int type)161 bool useShadedFills(int type) override { return (type < 4 && level >= psLevel2) || (type == 7 && level >= psLevel3); } 162 163 // Does this device use drawForm()? If this returns false, 164 // form-type XObjects will be interpreted (i.e., unrolled). useDrawForm()165 bool useDrawForm() override { return preloadImagesForms; } 166 167 // Does this device use beginType3Char/endType3Char? Otherwise, 168 // text in Type 3 fonts will be drawn with drawChar/drawString. interpretType3Chars()169 bool interpretType3Chars() override { return false; } 170 needClipToCropBox()171 bool needClipToCropBox() override { return mode == psModeEPS; } 172 173 //----- header/trailer (used only if manualCtrl is true) 174 175 // Write the document-level header. 176 void writeHeader(int nPages, const PDFRectangle *mediaBox, const PDFRectangle *cropBox, int pageRotate, const char *title); 177 178 // Write the Xpdf procset. 179 void writeXpdfProcset(); 180 181 // Write the trailer for the current page. 182 void writePageTrailer(); 183 184 // Write the document trailer. 185 void writeTrailer(); 186 187 //----- initialization and control 188 189 // Check to see if a page slice should be displayed. If this 190 // returns false, the page display is aborted. Typically, an 191 // OutputDev will use some alternate means to display the page 192 // before returning false. 193 bool checkPageSlice(Page *page, double hDPI, double vDPI, int rotate, bool useMediaBox, bool crop, int sliceX, int sliceY, int sliceW, int sliceH, bool printing, bool (*abortCheckCbk)(void *data) = nullptr, 194 void *abortCheckCbkData = nullptr, bool (*annotDisplayDecideCbk)(Annot *annot, void *user_data) = nullptr, void *annotDisplayDecideCbkData = nullptr) override; 195 196 // Start a page. 197 void startPage(int pageNum, GfxState *state, XRef *xref) override; 198 199 // End a page. 200 void endPage() override; 201 202 //----- save/restore graphics state 203 void saveState(GfxState *state) override; 204 void restoreState(GfxState *state) override; 205 206 //----- update graphics state 207 void updateCTM(GfxState *state, double m11, double m12, double m21, double m22, double m31, double m32) override; 208 void updateLineDash(GfxState *state) override; 209 void updateFlatness(GfxState *state) override; 210 void updateLineJoin(GfxState *state) override; 211 void updateLineCap(GfxState *state) override; 212 void updateMiterLimit(GfxState *state) override; 213 void updateLineWidth(GfxState *state) override; 214 void updateFillColorSpace(GfxState *state) override; 215 void updateStrokeColorSpace(GfxState *state) override; 216 void updateFillColor(GfxState *state) override; 217 void updateStrokeColor(GfxState *state) override; 218 void updateFillOverprint(GfxState *state) override; 219 void updateStrokeOverprint(GfxState *state) override; 220 void updateOverprintMode(GfxState *state) override; 221 void updateTransfer(GfxState *state) override; 222 223 //----- update text state 224 void updateFont(GfxState *state) override; 225 void updateTextMat(GfxState *state) override; 226 void updateCharSpace(GfxState *state) override; 227 void updateRender(GfxState *state) override; 228 void updateRise(GfxState *state) override; 229 void updateWordSpace(GfxState *state) override; 230 void updateHorizScaling(GfxState *state) override; 231 void updateTextPos(GfxState *state) override; 232 void updateTextShift(GfxState *state, double shift) override; 233 void saveTextPos(GfxState *state) override; 234 void restoreTextPos(GfxState *state) override; 235 236 //----- path painting 237 void stroke(GfxState *state) override; 238 void fill(GfxState *state) override; 239 void eoFill(GfxState *state) override; 240 bool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, GfxTilingPattern *tPat, const double *mat, int x0, int y0, int x1, int y1, double xStep, double yStep) override; 241 bool functionShadedFill(GfxState *state, GfxFunctionShading *shading) override; 242 bool axialShadedFill(GfxState *state, GfxAxialShading *shading, double /*tMin*/, double /*tMax*/) override; 243 bool radialShadedFill(GfxState *state, GfxRadialShading *shading, double /*sMin*/, double /*sMax*/) override; 244 bool patchMeshShadedFill(GfxState *state, GfxPatchMeshShading *shading) override; 245 246 //----- path clipping 247 void clip(GfxState *state) override; 248 void eoClip(GfxState *state) override; 249 void clipToStrokePath(GfxState *state) override; 250 251 //----- text drawing 252 void drawString(GfxState *state, const GooString *s) override; 253 void beginTextObject(GfxState *state) override; 254 void endTextObject(GfxState *state) override; 255 256 //----- image drawing 257 void drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool interpolate, bool inlineImg) override; 258 void setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool inlineImg, double *baseMatrix) override; 259 void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) override; 260 void drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, const int *maskColors, bool inlineImg) override; 261 void drawMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, bool maskInvert, bool maskInterpolate) override; 262 263 #ifdef OPI_SUPPORT 264 //----- OPI functions 265 void opiBegin(GfxState *state, Dict *opiDict) override; 266 void opiEnd(GfxState *state, Dict *opiDict) override; 267 #endif 268 269 //----- Type 3 font operators 270 void type3D0(GfxState *state, double wx, double wy) override; 271 void type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury) override; 272 273 //----- form XObjects 274 void drawForm(Ref ref) override; 275 276 //----- PostScript XObjects 277 void psXObject(Stream *psStream, Stream *level1Stream) override; 278 279 //----- miscellaneous setOffset(double x,double y)280 void setOffset(double x, double y) 281 { 282 tx0 = x; 283 ty0 = y; 284 } setScale(double x,double y)285 void setScale(double x, double y) 286 { 287 xScale0 = x; 288 yScale0 = y; 289 } setRotate(int rotateA)290 void setRotate(int rotateA) { rotate0 = rotateA; } setClip(double llx,double lly,double urx,double ury)291 void setClip(double llx, double lly, double urx, double ury) 292 { 293 clipLLX0 = llx; 294 clipLLY0 = lly; 295 clipURX0 = urx; 296 clipURY0 = ury; 297 } setUnderlayCbk(void (* cbk)(PSOutputDev * psOut,void * data),void * data)298 void setUnderlayCbk(void (*cbk)(PSOutputDev *psOut, void *data), void *data) 299 { 300 underlayCbk = cbk; 301 underlayCbkData = data; 302 } setOverlayCbk(void (* cbk)(PSOutputDev * psOut,void * data),void * data)303 void setOverlayCbk(void (*cbk)(PSOutputDev *psOut, void *data), void *data) 304 { 305 overlayCbk = cbk; 306 overlayCbkData = data; 307 } setDisplayText(bool display)308 void setDisplayText(bool display) { displayText = display; } 309 setPSCenter(bool center)310 void setPSCenter(bool center) { psCenter = center; } setPSExpandSmaller(bool expand)311 void setPSExpandSmaller(bool expand) { psExpandSmaller = expand; } setPSShrinkLarger(bool shrink)312 void setPSShrinkLarger(bool shrink) { psShrinkLarger = shrink; } setOverprintPreview(bool overprintPreviewA)313 void setOverprintPreview(bool overprintPreviewA) { overprintPreview = overprintPreviewA; } setRasterAntialias(bool a)314 void setRasterAntialias(bool a) { rasterAntialias = a; } setForceRasterize(PSForceRasterize f)315 void setForceRasterize(PSForceRasterize f) { forceRasterize = f; } setRasterResolution(double r)316 void setRasterResolution(double r) { rasterResolution = r; } setRasterMono(bool b)317 void setRasterMono(bool b) 318 { 319 processColorFormat = splashModeMono8; 320 processColorFormatSpecified = true; 321 } 322 setUncompressPreloadedImages(bool b)323 void setUncompressPreloadedImages(bool b) { uncompressPreloadedImages = b; } 324 getEmbedType1()325 bool getEmbedType1() const { return embedType1; } getEmbedTrueType()326 bool getEmbedTrueType() const { return embedTrueType; } getEmbedCIDPostScript()327 bool getEmbedCIDPostScript() const { return embedCIDPostScript; } getEmbedCIDTrueType()328 bool getEmbedCIDTrueType() const { return embedCIDTrueType; } getFontPassthrough()329 bool getFontPassthrough() const { return fontPassthrough; } getOptimizeColorSpace()330 bool getOptimizeColorSpace() const { return optimizeColorSpace; } getPassLevel1CustomColor()331 bool getPassLevel1CustomColor() const { return passLevel1CustomColor; } getEnableLZW()332 bool getEnableLZW() const { return enableLZW; }; getEnableFlate()333 bool getEnableFlate() const 334 #ifdef ENABLE_ZLIB 335 { 336 return enableFlate; 337 } 338 #else 339 { 340 return false; 341 } 342 #endif setEmbedType1(bool b)343 void setEmbedType1(bool b) { embedType1 = b; } setEmbedTrueType(bool b)344 void setEmbedTrueType(bool b) { embedTrueType = b; } setEmbedCIDPostScript(bool b)345 void setEmbedCIDPostScript(bool b) { embedCIDPostScript = b; } setEmbedCIDTrueType(bool b)346 void setEmbedCIDTrueType(bool b) { embedCIDTrueType = b; } setFontPassthrough(bool b)347 void setFontPassthrough(bool b) { fontPassthrough = b; } setOptimizeColorSpace(bool b)348 void setOptimizeColorSpace(bool b) { optimizeColorSpace = b; } setPassLevel1CustomColor(bool b)349 void setPassLevel1CustomColor(bool b) { passLevel1CustomColor = b; } setPreloadImagesForms(bool b)350 void setPreloadImagesForms(bool b) { preloadImagesForms = b; } setGenerateOPI(bool b)351 void setGenerateOPI(bool b) { generateOPI = b; } setUseASCIIHex(bool b)352 void setUseASCIIHex(bool b) { useASCIIHex = b; } setUseBinary(bool b)353 void setUseBinary(bool b) { useBinary = b; } setEnableLZW(bool b)354 void setEnableLZW(bool b) { enableLZW = b; } setEnableFlate(bool b)355 void setEnableFlate(bool b) { enableFlate = b; } 356 setProcessColorFormat(SplashColorMode format)357 void setProcessColorFormat(SplashColorMode format) 358 { 359 processColorFormat = format; 360 processColorFormatSpecified = true; 361 } 362 363 private: 364 void init(PSOutputFunc outputFuncA, void *outputStreamA, PSFileType fileTypeA, char *psTitleA, PDFDoc *doc, const std::vector<int> &pages, PSOutMode modeA, int imgLLXA, int imgLLYA, int imgURXA, int imgURYA, bool manualCtrlA, 365 int paperWidthA, int paperHeightA, bool noCropA, bool duplexA, PSLevel levelA); 366 void postInit(); 367 void setupResources(Dict *resDict); 368 void setupFonts(Dict *resDict); 369 void setupFont(GfxFont *font, Dict *parentResDict); 370 void setupEmbeddedType1Font(Ref *id, GooString *psName); 371 void updateFontMaxValidGlyph(GfxFont *font, int maxValidGlyph); 372 void setupExternalType1Font(GooString *fileName, GooString *psName); 373 void setupEmbeddedType1CFont(GfxFont *font, Ref *id, GooString *psName); 374 void setupEmbeddedOpenTypeT1CFont(GfxFont *font, Ref *id, GooString *psName); 375 void setupEmbeddedTrueTypeFont(GfxFont *font, Ref *id, GooString *psName); 376 void setupExternalTrueTypeFont(GfxFont *font, GooString *fileName, GooString *psName); 377 void setupEmbeddedCIDType0Font(GfxFont *font, Ref *id, GooString *psName); 378 void setupEmbeddedCIDTrueTypeFont(GfxFont *font, Ref *id, GooString *psName, bool needVerticalMetrics); 379 void setupExternalCIDTrueTypeFont(GfxFont *font, GooString *fileName, GooString *psName, bool needVerticalMetrics); 380 void setupEmbeddedOpenTypeCFFFont(GfxFont *font, Ref *id, GooString *psName); 381 void setupType3Font(GfxFont *font, GooString *psName, Dict *parentResDict); 382 GooString *makePSFontName(GfxFont *font, const Ref *id); 383 void setupImages(Dict *resDict); 384 void setupImage(Ref id, Stream *str, bool mask); 385 void setupForms(Dict *resDict); 386 void setupForm(Ref id, Object *strObj); 387 void addProcessColor(double c, double m, double y, double k); 388 void addCustomColor(GfxSeparationColorSpace *sepCS); 389 void doPath(const GfxPath *path); 390 void maskToClippingPath(Stream *maskStr, int maskWidth, int maskHeight, bool maskInvert); 391 void doImageL1(Object *ref, GfxImageColorMap *colorMap, bool invert, bool inlineImg, Stream *str, int width, int height, int len, const int *maskColors, Stream *maskStr, int maskWidth, int maskHeight, bool maskInvert); 392 void doImageL1Sep(Object *ref, GfxImageColorMap *colorMap, bool invert, bool inlineImg, Stream *str, int width, int height, int len, const int *maskColors, Stream *maskStr, int maskWidth, int maskHeight, bool maskInvert); 393 void doImageL2(GfxState *state, Object *ref, GfxImageColorMap *colorMap, bool invert, bool inlineImg, Stream *str, int width, int height, int len, const int *maskColors, Stream *maskStr, int maskWidth, int maskHeight, bool maskInvert); 394 void doImageL3(GfxState *state, Object *ref, GfxImageColorMap *colorMap, bool invert, bool inlineImg, Stream *str, int width, int height, int len, const int *maskColors, Stream *maskStr, int maskWidth, int maskHeight, bool maskInvert); 395 void dumpColorSpaceL2(GfxState *state, GfxColorSpace *colorSpace, bool genXform, bool updateColors, bool map01); 396 bool tilingPatternFillL1(GfxState *state, Catalog *cat, Object *str, const double *pmat, int paintType, int tilingType, Dict *resDict, const double *mat, const double *bbox, int x0, int y0, int x1, int y1, double xStep, double yStep); 397 bool tilingPatternFillL2(GfxState *state, Catalog *cat, Object *str, const double *pmat, int paintType, int tilingType, Dict *resDict, const double *mat, const double *bbox, int x0, int y0, int x1, int y1, double xStep, double yStep); 398 399 #ifdef OPI_SUPPORT 400 void opiBegin20(GfxState *state, Dict *dict); 401 void opiBegin13(GfxState *state, Dict *dict); 402 void opiTransform(GfxState *state, double x0, double y0, double *x1, double *y1); 403 #endif 404 void cvtFunction(const Function *func, bool invertPSFunction = false); 405 GooString *filterPSName(const GooString *name); 406 407 // Write the document-level setup. 408 void writeDocSetup(Catalog *catalog, const std::vector<int> &pageList, bool duplexA); 409 410 void writePSChar(char c); 411 void writePS(const char *s); 412 void writePSBuf(const char *s, int len); 413 void writePSFmt(const char *fmt, ...); 414 void writePSString(const std::string &s); 415 void writePSName(const char *s); 416 GooString *filterPSLabel(GooString *label, bool *needParens = nullptr); 417 void writePSTextLine(const GooString *s); 418 419 PSLevel level; // PostScript level (1, 2, separation) 420 PSOutMode mode; // PostScript mode (PS, EPS, form) 421 int paperWidth; // width of paper, in pts 422 int paperHeight; // height of paper, in pts 423 bool paperMatch; // true if paper size is set to match each page 424 int prevWidth; // width of previous page 425 // (only psModePSOrigPageSizes output mode) 426 int prevHeight; // height of previous page 427 // (only psModePSOrigPageSizes output mode) 428 int imgLLX, imgLLY, // imageable area, in pts 429 imgURX, imgURY; 430 bool noCrop; 431 bool duplex; 432 std::vector<int> pages; 433 char *psTitle; 434 bool postInitDone; // true if postInit() was called 435 436 PSOutputFunc outputFunc; 437 void *outputStream; 438 PSFileType fileType; // file / pipe / stdout 439 bool manualCtrl; 440 int seqPage; // current sequential page number 441 void (*underlayCbk)(PSOutputDev *psOut, void *data); 442 void *underlayCbkData; 443 void (*overlayCbk)(PSOutputDev *psOut, void *data); 444 void *overlayCbkData; 445 GooString *(*customCodeCbk)(PSOutputDev *psOut, PSOutCustomCodeLocation loc, int n, void *data); 446 void *customCodeCbkData; 447 448 PDFDoc *doc; 449 XRef *xref; // the xref table for this PDF file 450 451 Ref *fontIDs; // list of object IDs of all used fonts 452 int fontIDLen; // number of entries in fontIDs array 453 int fontIDSize; // size of fontIDs array 454 std::set<int> resourceIDs; // list of object IDs of objects containing Resources we've already set up 455 std::unordered_set<std::string> fontNames; // all used font names 456 std::unordered_map<std::string, int> perFontMaxValidGlyph; // max valid glyph of each font 457 PST1FontName *t1FontNames; // font names for Type 1/1C fonts 458 int t1FontNameLen; // number of entries in t1FontNames array 459 int t1FontNameSize; // size of t1FontNames array 460 PSFont8Info *font8Info; // info for 8-bit fonts 461 int font8InfoLen; // number of entries in font8Info array 462 int font8InfoSize; // size of font8Info array 463 PSFont16Enc *font16Enc; // encodings for substitute 16-bit fonts 464 int font16EncLen; // number of entries in font16Enc array 465 int font16EncSize; // size of font16Enc array 466 Ref *imgIDs; // list of image IDs for in-memory images 467 int imgIDLen; // number of entries in imgIDs array 468 int imgIDSize; // size of imgIDs array 469 Ref *formIDs; // list of IDs for predefined forms 470 int formIDLen; // number of entries in formIDs array 471 int formIDSize; // size of formIDs array 472 int numSaves; // current number of gsaves 473 int numTilingPatterns; // current number of nested tiling patterns 474 int nextFunc; // next unique number to use for a function 475 476 std::vector<PSOutPaperSize *> *paperSizes; // list of used paper sizes, if paperMatch 477 // is true 478 std::map<int, int> pagePaperSize; // page num to paperSize entry mapping 479 double tx0, ty0; // global translation 480 double xScale0, yScale0; // global scaling 481 int rotate0; // rotation angle (0, 90, 180, 270) 482 double clipLLX0, clipLLY0, clipURX0, clipURY0; 483 double tx, ty; // global translation for current page 484 double xScale, yScale; // global scaling for current page 485 int rotate; // rotation angle for current page 486 double epsX1, epsY1, // EPS bounding box (unrotated) 487 epsX2, epsY2; 488 489 GooString *embFontList; // resource comments for embedded fonts 490 491 int processColors; // used process colors 492 PSOutCustomColor // used custom colors 493 *customColors; 494 495 bool haveTextClip; // set if text has been drawn with a 496 // clipping render mode 497 498 bool inType3Char; // inside a Type 3 CharProc 499 bool inUncoloredPattern; // inside a uncolored pattern (PaintType = 2) 500 GooString *t3String; // Type 3 content string 501 double t3WX, t3WY, // Type 3 character parameters 502 t3LLX, t3LLY, t3URX, t3URY; 503 bool t3FillColorOnly; // operators should only use the fill color 504 bool t3Cacheable; // cleared if char is not cacheable 505 bool t3NeedsRestore; // set if a 'q' operator was issued 506 PSForceRasterize forceRasterize; // controls the rasterization of pages into images 507 bool displayText; // displayText 508 bool psCenter; // center pages on the paper 509 bool psExpandSmaller = false; // expand smaller pages to fill paper 510 bool psShrinkLarger = true; // shrink larger pages to fit paper 511 bool overprintPreview = false; // enable overprint preview 512 bool rasterAntialias; // antialias on rasterize 513 bool uncompressPreloadedImages; 514 double rasterResolution; // PostScript rasterization resolution (dpi) 515 bool embedType1; // embed Type 1 fonts? 516 bool embedTrueType; // embed TrueType fonts? 517 bool embedCIDPostScript; // embed CID PostScript fonts? 518 bool embedCIDTrueType; // embed CID TrueType fonts? 519 bool fontPassthrough; // pass all fonts through as-is? 520 bool optimizeColorSpace; // false to keep gray RGB images in their original color space 521 // true to optimize gray images to DeviceGray color space 522 bool passLevel1CustomColor; // false to convert all custom colors to CMYK 523 // true to pass custom colors 524 // has effect only when doing a level1sep 525 bool preloadImagesForms; // preload PostScript images and forms into 526 // memory 527 bool generateOPI; // generate PostScript OPI comments? 528 bool useASCIIHex; // use ASCIIHex instead of ASCII85? 529 bool useBinary; // use binary instead of hex 530 bool enableLZW; // enable LZW compression 531 bool enableFlate; // enable Flate compression 532 533 SplashColorMode processColorFormat; 534 bool processColorFormatSpecified; 535 536 std::unordered_set<std::string> iccEmitted; // contains ICCBased CSAs that have been emitted 537 538 #ifdef OPI_SUPPORT 539 int opi13Nest; // nesting level of OPI 1.3 objects 540 int opi20Nest; // nesting level of OPI 2.0 objects 541 #endif 542 543 bool ok; // set up ok? 544 std::set<int> patternsBeingTiled; // the patterns that are being tiled 545 546 friend class WinPDFPrinter; 547 }; 548 549 #endif 550