Документация PDFiumVCL

ObjectCount property

Эта запись API сохраняет идентификаторы, сигнатуры, блоки кода и термины PDF в исходном виде.
Component: TPdf  ·  Unit: PDFium
Read-only number of page objects (text, path, image, shading, form) at the current page.

Syntax

property ObjectCount: Integer; // read only

Description

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).

Remarks

Example

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;

See Also

ObjectHandle, ObjectBounds, ObjectTransparent