EnumPageElements
Extraction, page manipulation
Description
Enumerates the text runs, image placements and painted paths of one page into the caller's array and returns the number of elements found, which may be larger than that array; an invalid page number yields 0.
Syntax
Delphi
Function TPDFlib.EnumPageElements(Page: Integer; Var Elements: Array Of TPDFlibPageElement): Integer;
Parameters
Page is the 1-based number of the page to inspect; the page is selected internally for the duration of the call and the previously selected page is restored afterwards, and a value outside 1..PageCount makes the function return 0. Elements is a caller-sized array of TPDFlibPageElement that receives the first Length(Elements) elements; each entry carries Kind, ContentLayer, the FirstInstruction/LastInstruction range, a rectangle in the current measurement unit and origin, the text, font name and size for ekText, the ImageID for ekImage, and the point count, closed flag and paint operator for ekPath.
Return values
The total number of elements found on the page, which may be greater than Length(Elements); excess elements are counted but not written, so the array is filled only from index 0 upward. The value is 0 when no document is open, the page number is invalid, or the page contains no text, image placement or painted path.
Remarks
Elements are grouped by kind rather than returned in stream order: all text runs first, then image placements, then painted paths, each in content-stream order within its group. Every element also receives an ElementID for the page-element inspection and editing calls, valid until the next page-element enumeration or a successful element mutation on this instance, so a measuring call with an empty array discards the snapshots it created and must be followed by the call that fills the real array. Image elements are emitted per Do placement rather than per resource entry, and a placement whose XObject cannot be matched to a document image is skipped. Text geometry comes from a text block when one is available for the run and from the run itself otherwise.