Coverage Report

Created: 2025-07-23 08:13

/src/poppler/poppler/PSOutputDev.h
Line
Count
Source (jump to first uncovered line)
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-2024 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, 2023, 2024 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
// Copyright (C) 2023, 2025 g10 Code GmbH, Author: Sune Stolborg Vuorela <sune@vuorela.dk>
34
//
35
// To see a description of the changes please see the Changelog file that
36
// came with your tarball or type make ChangeLog if you are building from git
37
//
38
//========================================================================
39
40
#ifndef PSOUTPUTDEV_H
41
#define PSOUTPUTDEV_H
42
43
#include "poppler-config.h"
44
#include "poppler_private_export.h"
45
#include <cstddef>
46
#include "Object.h"
47
#include "GfxState.h"
48
#include "GlobalParams.h"
49
#include "OutputDev.h"
50
#include "fofi/FoFiBase.h"
51
#include <set>
52
#include <map>
53
#include <vector>
54
#include <unordered_set>
55
#include <unordered_map>
56
#include <string>
57
58
#include "splash/Splash.h"
59
60
class PDFDoc;
61
class XRef;
62
class Function;
63
class GfxPath;
64
class GfxFont;
65
class GfxColorSpace;
66
class GfxSeparationColorSpace;
67
class PDFRectangle;
68
struct PST1FontName;
69
struct PSFont8Info;
70
struct PSFont16Enc;
71
class PSOutCustomColor;
72
struct PSOutPaperSize;
73
class PSOutputDev;
74
75
//------------------------------------------------------------------------
76
// PSOutputDev
77
//------------------------------------------------------------------------
78
79
enum PSLevel
80
{
81
    psLevel1,
82
    psLevel1Sep,
83
    psLevel2,
84
    psLevel2Sep,
85
    psLevel3,
86
    psLevel3Sep
87
};
88
89
enum PSOutMode
90
{
91
    psModePS,
92
    psModeEPS,
93
    psModeForm
94
};
95
96
enum PSFileType
97
{
98
    psFile, // write to file
99
    psPipe, // write to pipe
100
    psStdout, // write to stdout
101
    psGeneric // write to a generic stream
102
};
103
104
enum PSOutCustomCodeLocation
105
{
106
    psOutCustomDocSetup,
107
    psOutCustomPageSetup
108
};
109
110
enum PSForceRasterize
111
{
112
    psRasterizeWhenNeeded, // default
113
    psAlwaysRasterize, // always rasterize, useful for testing
114
    psNeverRasterize // never rasterize, may produce incorrect output
115
};
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(FoFiOutputFunc 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.
142
7.16k
    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.)
148
20.9k
    bool upsideDown() override { return false; }
149
150
    // Does this device use drawChar() or drawString()?
151
2.79M
    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.
156
4.49k
    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.
161
1.67k
    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).
165
5.46k
    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.
169
14.0k
    bool interpretType3Chars() override { return false; }
170
171
10.4k
    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
280
    void setOffset(double x, double y)
281
0
    {
282
0
        tx0 = x;
283
0
        ty0 = y;
284
0
    }
285
    void setScale(double x, double y)
286
0
    {
287
0
        xScale0 = x;
288
0
        yScale0 = y;
289
0
    }
290
0
    void setRotate(int rotateA) { rotate0 = rotateA; }
291
    void setClip(double llx, double lly, double urx, double ury)
292
0
    {
293
0
        clipLLX0 = llx;
294
0
        clipLLY0 = lly;
295
0
        clipURX0 = urx;
296
0
        clipURY0 = ury;
297
0
    }
298
    void setUnderlayCbk(void (*cbk)(PSOutputDev *psOut, void *data), void *data)
299
0
    {
300
0
        underlayCbk = cbk;
301
0
        underlayCbkData = data;
302
0
    }
303
    void setOverlayCbk(void (*cbk)(PSOutputDev *psOut, void *data), void *data)
304
0
    {
305
0
        overlayCbk = cbk;
306
0
        overlayCbkData = data;
307
0
    }
308
0
    void setDisplayText(bool display) { displayText = display; }
309
310
0
    void setPSCenter(bool center) { psCenter = center; }
311
0
    void setPSExpandSmaller(bool expand) { psExpandSmaller = expand; }
312
0
    void setPSShrinkLarger(bool shrink) { psShrinkLarger = shrink; }
313
0
    void setOverprintPreview(bool overprintPreviewA) { overprintPreview = overprintPreviewA; }
314
0
    void setRasterAntialias(bool a) { rasterAntialias = a; }
315
0
    void setForceRasterize(PSForceRasterize f) { forceRasterize = f; }
316
0
    void setRasterResolution(double r) { rasterResolution = r; }
317
    void setRasterMono(bool b)
318
0
    {
319
0
        processColorFormat = splashModeMono8;
320
0
        processColorFormatSpecified = true;
321
0
    }
322
323
0
    void setUncompressPreloadedImages(bool b) { uncompressPreloadedImages = b; }
324
325
5.62k
    bool getEmbedType1() const { return embedType1; }
326
2.05k
    bool getEmbedTrueType() const { return embedTrueType; }
327
728
    bool getEmbedCIDPostScript() const { return embedCIDPostScript; }
328
1.11k
    bool getEmbedCIDTrueType() const { return embedCIDTrueType; }
329
6.76k
    bool getFontPassthrough() const { return fontPassthrough; }
330
616
    bool getOptimizeColorSpace() const { return optimizeColorSpace; }
331
0
    bool getPassLevel1CustomColor() const { return passLevel1CustomColor; }
332
54.4k
    bool getEnableLZW() const { return enableLZW; };
333
622
    bool getEnableFlate() const { return enableFlate; }
334
0
    void setEmbedType1(bool b) { embedType1 = b; }
335
0
    void setEmbedTrueType(bool b) { embedTrueType = b; }
336
0
    void setEmbedCIDPostScript(bool b) { embedCIDPostScript = b; }
337
0
    void setEmbedCIDTrueType(bool b) { embedCIDTrueType = b; }
338
0
    void setFontPassthrough(bool b) { fontPassthrough = b; }
339
0
    void setOptimizeColorSpace(bool b) { optimizeColorSpace = b; }
340
0
    void setPassLevel1CustomColor(bool b) { passLevel1CustomColor = b; }
341
0
    void setPreloadImagesForms(bool b) { preloadImagesForms = b; }
342
0
    void setGenerateOPI(bool b) { generateOPI = b; }
343
0
    void setUseASCIIHex(bool b) { useASCIIHex = b; }
344
0
    void setUseBinary(bool b) { useBinary = b; }
345
0
    void setEnableLZW(bool b) { enableLZW = b; }
346
0
    void setEnableFlate(bool b) { enableFlate = b; }
347
348
    void setProcessColorFormat(SplashColorMode format)
349
0
    {
350
0
        processColorFormat = format;
351
0
        processColorFormatSpecified = true;
352
0
    }
353
354
private:
355
    struct PSOutPaperSize
356
    {
357
        PSOutPaperSize() = default;
358
7.16k
        PSOutPaperSize(std::string &&nameA, int wA, int hA) : name(nameA), w(wA), h(hA) { }
359
7.16k
        ~PSOutPaperSize() = default;
360
        PSOutPaperSize &operator=(const PSOutPaperSize &) = delete;
361
        std::string name;
362
        int w, h;
363
    };
364
365
    void init(FoFiOutputFunc 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,
366
              int paperWidthA, int paperHeightA, bool noCropA, bool duplexA, PSLevel levelA);
367
    void postInit();
368
    void setupResources(Dict *resDict);
369
    void setupFonts(Dict *resDict);
370
    void setupFont(GfxFont *font, Dict *parentResDict);
371
    void setupEmbeddedType1Font(Ref *id, GooString *psName);
372
    void updateFontMaxValidGlyph(GfxFont *font, int maxValidGlyph);
373
    void setupExternalType1Font(const std::string &fileName, GooString *psName);
374
    void setupEmbeddedType1CFont(GfxFont *font, Ref *id, GooString *psName);
375
    void setupEmbeddedOpenTypeT1CFont(GfxFont *font, Ref *id, GooString *psName, int faceIndex);
376
    void setupEmbeddedTrueTypeFont(GfxFont *font, Ref *id, GooString *psName, int faceIndex);
377
    void setupExternalTrueTypeFont(GfxFont *font, const std::string &fileName, GooString *psName, int faceIndex);
378
    void setupEmbeddedCIDType0Font(GfxFont *font, Ref *id, GooString *psName);
379
    void setupEmbeddedCIDTrueTypeFont(GfxFont *font, Ref *id, GooString *psName, bool needVerticalMetrics, int faceIndex);
380
    void setupExternalCIDTrueTypeFont(GfxFont *font, const std::string &fileName, GooString *psName, bool needVerticalMetrics, int faceIndex);
381
    void setupEmbeddedOpenTypeCFFFont(GfxFont *font, Ref *id, GooString *psName, int faceIndex);
382
    void setupType3Font(GfxFont *font, GooString *psName, Dict *parentResDict);
383
    std::unique_ptr<GooString> makePSFontName(GfxFont *font, const Ref *id);
384
    void setupImages(Dict *resDict);
385
    void setupImage(Ref id, Stream *str, bool mask);
386
    void setupForms(Dict *resDict);
387
    void setupForm(Ref id, Object *strObj);
388
    void addProcessColor(double c, double m, double y, double k);
389
    void addCustomColor(GfxSeparationColorSpace *sepCS);
390
    void doPath(const GfxPath *path);
391
    void maskToClippingPath(Stream *maskStr, int maskWidth, int maskHeight, bool maskInvert);
392
    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);
393
    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);
394
    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);
395
    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);
396
    void dumpColorSpaceL2(GfxState *state, GfxColorSpace *colorSpace, bool genXform, bool updateColors, bool map01);
397
    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);
398
    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);
399
400
#ifdef OPI_SUPPORT
401
    void opiBegin20(GfxState *state, Dict *dict);
402
    void opiBegin13(GfxState *state, Dict *dict);
403
    void opiTransform(GfxState *state, double x0, double y0, double *x1, double *y1);
404
#endif
405
    void cvtFunction(const Function *func, bool invertPSFunction = false);
406
    static std::string filterPSName(const std::string &name);
407
408
    // Write the document-level setup.
409
    void writeDocSetup(Catalog *catalog, const std::vector<int> &pageList, bool duplexA);
410
411
    void writePSChar(char c);
412
    void writePS(const char *s);
413
    void writePSBuf(const char *s, int len);
414
    void writePSFmt(const char *fmt, ...) GOOSTRING_FORMAT;
415
    void writePSString(const std::string &s);
416
    void writePSName(const char *s);
417
    GooString *filterPSLabel(GooString *label, bool *needParens = nullptr);
418
    void writePSTextLine(const std::string &s);
419
420
    PSLevel level; // PostScript level (1, 2, separation)
421
    PSOutMode mode; // PostScript mode (PS, EPS, form)
422
    int paperWidth; // width of paper, in pts
423
    int paperHeight; // height of paper, in pts
424
    bool paperMatch; // true if paper size is set to match each page
425
    int prevWidth; // width of previous page
426
                   // (only psModePSOrigPageSizes output mode)
427
    int prevHeight; // height of previous page
428
                    // (only psModePSOrigPageSizes output mode)
429
    int imgLLX, imgLLY, // imageable area, in pts
430
            imgURX, imgURY;
431
    bool noCrop;
432
    bool duplex;
433
    std::vector<int> pages;
434
    char *psTitle;
435
    bool postInitDone; // true if postInit() was called
436
437
    FoFiOutputFunc outputFunc;
438
    void *outputStream;
439
    PSFileType fileType; // file / pipe / stdout
440
    bool manualCtrl;
441
    int seqPage; // current sequential page number
442
    void (*underlayCbk)(PSOutputDev *psOut, void *data);
443
    void *underlayCbkData;
444
    void (*overlayCbk)(PSOutputDev *psOut, void *data);
445
    void *overlayCbkData;
446
    GooString *(*customCodeCbk)(PSOutputDev *psOut, PSOutCustomCodeLocation loc, int n, void *data);
447
    void *customCodeCbkData;
448
449
    PDFDoc *doc;
450
    XRef *xref; // the xref table for this PDF file
451
452
    std::vector<Ref> fontIDs; // list of object IDs of all used fonts
453
    std::set<int> resourceIDs; // list of object IDs of objects containing Resources we've already set up
454
    std::unordered_set<std::string> fontNames; // all used font names
455
    std::unordered_map<std::string, int> perFontMaxValidGlyph; // max valid glyph of each font
456
    std::vector<PST1FontName> t1FontNames; // font names for Type 1/1C fonts
457
    std::vector<PSFont8Info> font8Info; // info for 8-bit fonts
458
    PSFont16Enc *font16Enc; // encodings for substitute 16-bit fonts
459
    int font16EncLen; // number of entries in font16Enc array
460
    int font16EncSize; // size of font16Enc array
461
    Ref *imgIDs; // list of image IDs for in-memory images
462
    int imgIDLen; // number of entries in imgIDs array
463
    int imgIDSize; // size of imgIDs array
464
    Ref *formIDs; // list of IDs for predefined forms
465
    int formIDLen; // number of entries in formIDs array
466
    int formIDSize; // size of formIDs array
467
    int numSaves; // current number of gsaves
468
    int numTilingPatterns; // current number of nested tiling patterns
469
    int nextFunc; // next unique number to use for a function
470
471
    std::vector<PSOutPaperSize> paperSizes; // list of used paper sizes, if paperMatch
472
                                            //   is true
473
    std::map<int, int> pagePaperSize; // page num to paperSize entry mapping
474
    double tx0, ty0; // global translation
475
    double xScale0, yScale0; // global scaling
476
    int rotate0; // rotation angle (0, 90, 180, 270)
477
    double clipLLX0, clipLLY0, clipURX0, clipURY0;
478
    double tx, ty; // global translation for current page
479
    double xScale, yScale; // global scaling for current page
480
    int rotate; // rotation angle for current page
481
    double epsX1, epsY1, // EPS bounding box (unrotated)
482
            epsX2, epsY2;
483
484
    GooString *embFontList; // resource comments for embedded fonts
485
486
    int processColors; // used process colors
487
    PSOutCustomColor // used custom colors
488
            *customColors;
489
490
    bool haveTextClip; // set if text has been drawn with a
491
                       //   clipping render mode
492
493
    bool inType3Char; // inside a Type 3 CharProc
494
    bool inUncoloredPattern; // inside a uncolored pattern (PaintType = 2)
495
    GooString *t3String; // Type 3 content string
496
    double t3WX, t3WY, // Type 3 character parameters
497
            t3LLX, t3LLY, t3URX, t3URY;
498
    bool t3FillColorOnly; // operators should only use the fill color
499
    bool t3Cacheable; // cleared if char is not cacheable
500
    bool t3NeedsRestore; // set if a 'q' operator was issued
501
    PSForceRasterize forceRasterize; // controls the rasterization of pages into images
502
    bool displayText; // displayText
503
    bool psCenter; // center pages on the paper
504
    bool psExpandSmaller = false; // expand smaller pages to fill paper
505
    bool psShrinkLarger = true; // shrink larger pages to fit paper
506
    bool overprintPreview = false; // enable overprint preview
507
    bool rasterAntialias; // antialias on rasterize
508
    bool uncompressPreloadedImages;
509
    double rasterResolution; // PostScript rasterization resolution (dpi)
510
    bool embedType1; // embed Type 1 fonts?
511
    bool embedTrueType; // embed TrueType fonts?
512
    bool embedCIDPostScript; // embed CID PostScript fonts?
513
    bool embedCIDTrueType; // embed CID TrueType fonts?
514
    bool fontPassthrough; // pass all fonts through as-is?
515
    bool optimizeColorSpace; // false to keep gray RGB images in their original color space
516
                             // true to optimize gray images to DeviceGray color space
517
    bool passLevel1CustomColor; // false to convert all custom colors to CMYK
518
                                // true to pass custom colors
519
                                // has effect only when doing a level1sep
520
    bool preloadImagesForms; // preload PostScript images and forms into
521
                             //   memory
522
    bool generateOPI; // generate PostScript OPI comments?
523
    bool useASCIIHex; // use ASCIIHex instead of ASCII85?
524
    bool useBinary; // use binary instead of hex
525
    bool enableLZW; // enable LZW compression
526
    bool enableFlate; // enable Flate compression
527
528
    SplashColorMode processColorFormat;
529
    bool processColorFormatSpecified;
530
531
    std::unordered_set<std::string> iccEmitted; // contains ICCBased CSAs that have been emitted
532
533
#ifdef OPI_SUPPORT
534
    int opi13Nest; // nesting level of OPI 1.3 objects
535
    int opi20Nest; // nesting level of OPI 2.0 objects
536
#endif
537
538
    bool ok; // set up ok?
539
    std::set<int> patternsBeingTiled; // the patterns that are being tiled
540
541
    friend class WinPDFPrinter;
542
};
543
544
#endif