PDFium Delphi Component Docs

StructureElementsForPage property

Component: TPdf  ·  Unit: PDFium
Returns the cached tagged structure tree of one page as a flat array of element records

Syntax

property StructureElementsForPage[PageNumber: Integer]: TPdfStructureElements; // read only

PageNumberInteger. One-based page index within the loaded document
ResultTPdfStructureElements. Array of TPdfStructureElement records in document traversal order

Description

The first access for a page parses the tagged structure tree with TPdfStructureReadOptions.Default limits, the same traversal used by ReadStructureElements, and returns the elements as managed records carrying level and parent links, type and title strings, alternate and actual text, language, marked content identifiers, attributes, table facts and associated file references

Every access returns a deep clone, so modifying a returned string or array cannot change the cached tree or the document. A page without tagged structure yields an empty array

Completed trees are retained in the bounded cache described by StructureCacheCapacity and measured against CacheBudgetBytes, so repeated reads of the same page cost one clone instead of one native walk

Remarks

Calling without an active document raises EPdfError, and a PageNumber outside one to PageCount raises EPdfError with the message Incorrect page number

The non-indexed StructureElements property forwards the current page to this lookup

Use ReadStructureElements or VisitStructureElements for custom limits or a streaming visitor that avoids collecting all elements

Example

Elements := Pdf.StructureElementsForPage[PageNumber];
for I := 0 to High(Elements) do
  if Elements[I].MarkedContentID >= 0 then
    LogMarkedContent(Elements[I].TypeName, Elements[I].Level);

See Also

StructureCacheCapacity, StructureCacheCount, StructureTraversal, StructureElements, TPdfView.StructureElements