PDFium Delphi Component Docs

GetObjectsByType method

Component: TPdf  ·  Unit: PDFium
List the indexes of every page object of one kind on the current page

Syntax

function GetObjectsByType(ObjType: TObjectType): TPdfIntegerArray;

ObjTypeTObjectType. Kind of object to collect: otText, otPath, otImage, otShading, or otForm
ResultTPdfIntegerArray. Zero-based object indexes in content-stream order. Empty when the page holds no object of that kind

Description

Saves the caller the loop over ObjectCount that filters on ObjectType. The returned values are indexes, not handles, so they can be passed straight to PageObjectInfo, PathInfo, or RemoveObject

Indexes are valid only until the page object list changes. Removing or inserting an object shifts every later index, so a loop that deletes objects should walk the array backwards

Example

var Images: TPdfIntegerArray;
var I: Integer;
Images := Pdf.GetObjectsByType(otImage);
for I := High(Images) downto 0 do
  Pdf.RemoveObject(Images[I]);

See Also

ObjectType, ObjectCount, PageObjectInfo, GetObjectText