WritePageContentLayer

Page manipulation

Description

Serialises a TPDFContentProgram back into one content layer of the selected page, replacing that layer's stream. It is the counterpart of ParsePageContentLayer: parse a layer into an editable instruction list, modify the list, then write it back. Round-tripping is the intended use, and the emitter is behaviour-preserving, so writing back an unmodified program renders the page exactly as before; deleting instructions from the program removes the corresponding marks from the page

Layers are written independently of each other, and a layer may legally start or end inside an open graphics object, so unbalanced q/Q or BT/ET within one layer is tolerated

Syntax

Delphi

Function TPDFlib.WritePageContentLayer(Layer: Integer; ContentProgram: TPDFContentProgram): Integer;

Parameters

LayerThe 1-based content layer to replace on the selected page; see GetPageContentLayerCount for how many layers the page has
ContentProgramThe program to serialise, typically the object returned by ParsePageContentLayer after editing; the caller remains responsible for freeing it

Return values

1The layer's stream was replaced with the serialised program
0No document is loaded, ContentProgram is nil, or the layer index is invalid

Remarks

The rewritten stream is stored deflated. Editing instructions through the TPDFContentProgram model keeps every other layer and page object untouched

See also

ParsePageContentLayer, GetPageContentLayerCount, EnumPageContentStates