ParsePageContentLayer

Page manipulation

Description

Decodes one content layer of the selected page into an editable TPDFContentProgram, the parsed instruction list of that layer's content stream. Each instruction pairs a PDF content operator (ISO 32000-1 Table 51) with its decoded operand objects, giving code a structured view of the page for inspection and editing

A page's /Contents entry holds one or more layers; query GetPageContentLayerCount for the count, pass a 1-based layer index here, and serialise an edited program back with WritePageContentLayer

Syntax

Delphi

Function TPDFlib.ParsePageContentLayer(Layer: Integer): TPDFContentProgram;

Parameters

Layer1-based index of the content layer to decode, between 1 and GetPageContentLayerCount

Return values

TPDFContentProgramThe decoded instruction list for the layer; the caller frees the object
nilNo document is selected, Layer is out of range, or the layer content is grossly damaged

Remarks

Each layer is edited independently; a layer may legally begin or end inside an open graphics object, so unbalanced q/Q or BT/ET within one layer is tolerated

Inline images are preserved verbatim, and unknown operators, for example vendor extensions inside BX/EX sections, round-trip unchanged

Numeric operands keep their source text, so writing the program back changes only the operands that were edited; operands set through SetOperand or created by an edit are written with four decimal places. The returned program has already been parsed, so setting its CanonicalNumbers property afterwards does not change the numbers it holds; to rewrite every number in canonical form, as NormalizeContentStreams does, set CanonicalNumbers to True and parse the program's own output again with Prog.Parse(Prog.Emit)

See also

GetPageContentLayerCount, WritePageContentLayer, EnumPageContentStates