EnumPageContentStatesEx

Page manipulation

Description

Traces selected-page instructions and optionally descends into Form XObject content using the graphics state and resource scope active at each Do operator

Syntax

Delphi

Function EnumPageContentStatesEx(AfterInstruction: Boolean; MaxFormDepth: Integer; Var States: Array Of TPDFlibContentGraphicsState): Integer;

Parameters

AfterInstruction selects snapshots immediately after each operator when true and immediately before each operator when false

MaxFormDepth selects the number of nested Form levels to execute, where zero retains page-level instructions only and values above 64 are limited to 64

States receives as many records as fit in the caller-supplied array

Return value

The total snapshot count, including records that do not fit in States, or zero when no document is selected or a page content layer cannot be parsed

Remarks

Call once with an empty array to obtain the count, allocate the destination, then call again to fill it

Form execution follows graphics-state isolation, form-matrix concatenation, /BBox clipping and current-resource selection

The child state inherits the effective UseBlackPtComp value active at its Do operator, then applies any Form-local ExtGState changes without leaking them back to the caller

A Form with its own /Resources dictionary uses that dictionary exclusively; a Form without one inherits the invoking resource dictionary for compatibility with earlier PDF files

Repeated Form streams are decoded and parsed once per enumeration, then executed independently for each invocation

Active-path cycle detection and the depth limit prevent unbounded recursion without suppressing valid reuse from separate invocation branches

When AfterInstruction is true, nested snapshots precede their containing Do snapshot because the operator completes after its descendants; before snapshots use the opposite pre-order

FormTraversalStatus and FormDescendantCount report whether each Form was enumerated or skipped, while invocation and parent fields reconstruct the call tree