property ObjectCount: Integer; // read only
返回与打开 PDF 文档关联的页面对象(文本、路径、图像、渐变、表单)数量。当 PageNumber 被赋值为不同的页面,或在插入或移除页面对象的变更调用之后,计数会改变
该值直接从底层 PDFium 引擎读取(要求 Active 为 True 且已加载当前页面)。当文档已关闭、在查询范围内没有页面对象(文本、路径、图像、渐变、表单)或该属性不适用于当前 PDF 时,结果为 0
该值通过 FPDFPage_CountObjects 从活动页面查询
Active 为 False 或相关 PDF 字典条目缺失时返回 0ObjectHandle[Index] 时,将 0 .. ObjectCount - 1 视为有效范围。超出范围的索引抛出 EPdfError
var
I: Integer;
begin
if not Pdf1.Active then Exit;
Memo1.Lines.Add(Format('%d page objects (text, path, image, shading, form)', [Pdf1.ObjectCount]));
for I := 0 to Pdf1.ObjectCount - 1 do
begin
// 检查每个条目
Memo1.Lines.Add(Format(' [%d]', [I]));
end;
end;