API referenceGraphics

pdfSetGStateFlags

Set/get a document-global compatibility/behavior bitmask

C
int32_t __stdcall pdfGetGStateFlags(PPDF IPDF);
BOOL32 __stdcall pdfSetGStateFlags(PPDF IPDF, TGStateFlags Flags, BOOL32 Reset);
Delphi
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 := Flagsregardless 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.

ParameterDescription
IPDFDocument handle.
FlagsThe full new flag bitmask — always REPLACES the previous value entirely.
ResetAccepted 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)

wrappers/dotnet/LumasPdf.cs
[return: MarshalAs(UnmanagedType.Bool)]
Area
Graphics
Category

Setters

Exported names

pdfSetGStateFlags

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.