PDFium Delphi Component Docs

RemoveObject method

Component: TPdf  ·  Unit: PDFium
Removes the specified page object from the current page. When DestroyObject is True, the removed object is released after removal. The page content stream is regenerated automatically

Syntax

procedure RemoveObject(Index: Integer; DestroyObject: Boolean = True);

IndexInteger. Zero-based index of the page object to remove (0 to ObjectCount - 1)
DestroyObjectBoolean. When True (default), the underlying PDFium object is freed after removal. Pass False to detach the object from the page without releasing its memory, for example when transferring it to another page

Description

RemoveObject deletes a page object from the current page by its zero-based index. Valid index values range from 0 to ObjectCount - 1. After the call, the page content stream is regenerated automatically so the change is reflected immediately

When DestroyObject is True (the default), the underlying PDFium object handle is released and its memory freed. When False, the object is merely detached from the page without being destroyed — this is useful when moving an object from one page to another, where the caller takes ownership of the handle

Because removing an object shifts the indices of all subsequent objects, take care when removing multiple objects in a loop: iterate from the highest index downward, or collect the indices to remove before starting the loop

Example

// Remove the last page object
if Pdf1.ObjectCount > 0 then
  Pdf1.RemoveObject(Pdf1.ObjectCount - 1);

// Remove all objects from highest index downward
var I: Integer;
begin
  for I := Pdf1.ObjectCount - 1 downto 0 do
    Pdf1.RemoveObject(I);
end;

Saved paragraph metadata

Since internal v3.403.0, direct logical text, object membership and ActualText changes clear affected saved paragraph cluster tables Geometry, style and metadata-only changes retain tables and regenerate complete represented shared mark scopes across adjacent nonempty streams Mark list membership is local to the selected object, while 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 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

ObjectCount, ObjectType, AddPath