function GetObjectsByType(ObjType: TObjectType): TPdfIntegerArray;
| ObjType | TObjectType. Kind of object to collect: otText, otPath, otImage, otShading, or otForm. |
| Result | TPdfIntegerArray. Zero-based object indexes in content-stream order. Empty when the page holds no object of that kind. |
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
var Images: TPdfIntegerArray;
var I: Integer;
Images := Pdf.GetObjectsByType(otImage);
for I := High(Images) downto 0 do
Pdf.RemoveObject(Images[I]);