function GetObjectsByType(ObjType: TObjectType): TPdfIntegerArray;
| ObjType | TObjectType。要收集的对象种类:otText、otPath、otImage、otShading 或 otForm |
| Result | TPdfIntegerArray。按内容流顺序的从零开始的对象索引。页面没有该种类对象时为空 |
为调用者省去遍历 ObjectCount 并按 ObjectType 过滤的循环。返回值是索引而非句柄,因此可直接传给 PageObjectInfo、PathInfo 或 RemoveObject
索引只在页面对象列表改变之前有效。删除或插入对象会使每个后续索引移位,因此删除对象的循环应反向遍历数组
var Images: TPdfIntegerArray;
var I: Integer;
Images := Pdf.GetObjectsByType(otImage);
for I := High(Images) downto 0 do
Pdf.RemoveObject(Images[I]);