int32_t __stdcall pdfGetGStateFlags(PPDF IPDF);
BOOL32 __stdcall pdfSetGStateFlags(PPDF IPDF, TGStateFlags Flags, BOOL32 Reset);
function pdfGetGStateFlags(const IPDF: PPDF): Integer; stdcall;
function pdfSetGStateFlags(const IPDF: PPDF; Flags: TGStateFlags; Reset: LongBool): LongBool; stdcall;
Purpose. Set/get a document-global compatibility/behavior bitmask (TGStateFlags — a Cardinal bit set, e.g. gfRestorePageCoords = 1, gfRealTopDownCoords = 2, gfNativeBlackWhite = 4, ... gfDisableJavascript = $800) that alters several engine-wide behaviors, unlike most of this chapter's other document-global settings.
Description. This one is real, but with a caveat: the setter performs a flat, unconditional assignment — FGStateFlags := Flags — regardless of the Reset argument. The ABI's Reset: BOOL32 parameter implies a choice between "replace the whole mask" and "merge/clear specific bits," but the implementation always replaces the entire mask; there is no way to set or clear an individual flag bit without first reading pdfGetGStateFlags, computing the new combined value in the caller, and passing the full result back — Reset's value has zero effect either way. Of the many defined bit constants, only two are actually consulted elsewhere in the codebase: gfRealTopDownCoords and gfRestorePageCoords (both read together during page-coordinate resolution) — the remaining flags (gfNativeBlackWhite, gfUseImageColorSpace, gfIgnoreICCProfiles, gfAnsiStringIsUTF8, gfRealPassThrough, gfNoBitmapAlpha, gfNoImageDuplCheck, gfNoObjCompression, gfComplexText, gfDisableJavascript) can be set and read back via this getter/setter pair but have no verified behavioral effect anywhere else in the codebase. Default value at document-open is 8 (gfUseImageColorSpace), diverging from the classic API's documented default.
Parameters.
| Parameter | Description |
|---|---|
IPDF | Document handle. |
Flags | The full new flag bitmask — always REPLACES the previous value entirely. |
Reset | Accepted but has no effect — the assignment is unconditional regardless of this value. |
Return value. pdfSetGStateFlags: True if IPDF is valid. pdfGetGStateFlags: the current bitmask; 0 if IPDF invalid.
Remarks. Only gfRealTopDownCoords/gfRestorePageCoords change engine behavior in this release; the remaining flags are accepted but have no effect.
See also. pdfSetOpacity (an inert sibling, for contrast — this one genuinely does something, just not what Reset implies).
C# (P/Invoke)
public static extern int pdfGetGStateFlags(IntPtr IPDF);
Getters
pdfGetGStateFlags
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.