ComposeDeferredPageLayers

Page layout, Vector graphics, Content streams

Description

Places every queued deferred layer on its target page in stable ascending z-index order

Syntax

Delphi

Function TPDFlib.ComposeDeferredPageLayers: Integer;

ActiveX

Function PDFlib::ComposeDeferredPageLayers() As Long

DLL

int DLComposeDeferredPageLayers(int InstanceID);

Return values

Returns the number of layers composed, or 0 when no layer is queued, recording is still active, the selected page is not the target page, its dimensions changed, or a captured form is unavailable

Remarks

The method sorts queued layers by z-index and recording sequence

Negative layers are inserted before the page's original content streams in ascending order, while zero and positive layers are appended after the original content streams in ascending order

Each composed layer adds one content stream containing one Form XObject placement, keeping composition cost independent of the number of drawing operations inside the layer

The selected font, active content layer, painter state, and kerning setting are restored after composition

A failed precondition leaves the queue available so the caller can reselect the target page, while a failure after page mutation clears the queue to prevent duplicate placement

Example

PDF.BeginDeferredPageLayer(-10);
DrawBackground(PDF);
PDF.EndDeferredPageLayer;

PDF.BeginDeferredPageLayer(10);
DrawForeground(PDF);
PDF.EndDeferredPageLayer;

if PDF.ComposeDeferredPageLayers<> 2 then
  HandleCompositionError;