PDFium Delphi Component Docs

SetText method

Component: TPdf  ·  Unit: PDFium
Replaces the Unicode text of an existing text page object on the current page

Syntax

procedure SetText(ObjectIndex: Integer; const Text: WString);

Description

Swaps the text content of the text page object at ObjectIndex (0 .. ObjectCount - 1) on the current page

To put a brand-new text object onto the page, call AddText instead

All edits to the current page are buffered in PDFium's in-memory representation. Call UpdatePage to refresh the rendering cache and SaveAs to persist the changes

Remarks

Example

begin
  if Pdf1.Active and (Pdf1.ObjectCount > 0) and (Pdf1.ObjectType[0] = otText) then
  begin
    Pdf1.SetText(0, 'Updated text');
    Pdf1.UpdatePage;
  end;
end;

Saved paragraph metadata

Since internal v3.403.0, direct logical text, object membership and ActualText changes clear the affected saved paragraph cluster tables Geometry, style and metadata-only changes retain the tables and regenerate complete represented shared mark scopes across adjacent nonempty streams Mark list membership is local to the selected object, whilst exact shared declarations keep their identity The bundled DLLs isolate named-property parameter edits; native builds without detachment reject a table-affecting logical change before mutation

Read the native character maps again after mutation or reload These low-level operations do not supply reviewed replacement semantics or repair arbitrary tagged ownership Use the batch semantic-edit policies when those values and bindings must be reviewed together See scope, ownership and remaining source-preservation limits

See Also

AddText, AddImage, AddPath