property ObjectCount: Integer; // read only
Returns the number of page objects (text, path, image, shading, form) associated with the open PDF document. The count changes when Page is assigned to a different page index, so it can be used as the upper bound of a for loop that walks through every ObjectHandle[Index].
The value is read directly from the underlying PDFium engine (requires Active to be True and a current page to be loaded). When the document is closed, has no page objects (text, path, image, shading, form) at the queried scope, or the property is not applicable for the current PDF, the result is 0.
Because this counter is computed lazily by PDFium on first access, the first call may trigger parsing of the relevant object stream (e.g. the page's /Annots array or the document's /Names tree). Subsequent calls are O(1).
0 when Active is False or when the relevant PDF dictionary entry is missing.0 .. ObjectCount - 1 as the valid range when reading ObjectHandle[Index]. Out-of-range indices raise 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
// inspect each item
Memo1.Lines.Add(Format(' [%d]', [I]));
end;
end;