CloneComponent

Document parts, variable data, document editing

Description

Abstract method of TPDFlibDynamicComponent that returns a caller-independent copy of the component including all mutable pagination state

Syntax

Function TPDFlibDynamicComponent.CloneComponent:
  TPDFlibDynamicComponent; Virtual; Abstract;

Remarks

Overrides must copy every field that Compose mutates, because the session composes on a working clone and commits that clone only after its Form XObject has been validated and placed

The session relies on the clone in several places: AttachComponent clones twice for the initial and current snapshots, ComposeNextLayout clones once per attempt for the working component, and CloneCurrentComponent clones the committed snapshot for inspection

The caller of CloneComponent owns the returned instance and frees it independently of the source component

A Nil result is treated as a cloning failure by the session, which then rejects the originating operation without changing stored state

Example

function TNumberedPagesComponent.CloneComponent:
  TPDFlibDynamicComponent;
begin
  Result := TNumberedPagesComponent.Create(FNextPage, FPageCount);
end;

Return values

New instanceAn independent copy whose later Compose calls cannot affect the source component
NilThe override could not produce a copy; the session rejects AttachComponent and composition attempts that depend on the clone

See also

TPDFlibDynamicComponent, TPDFlibDynamicComponentSession, Compose, CloneCurrentComponent, AttachComponent