GetObjectByPath

Document properties, Content Extraction

Description

Reads any node of the object tree through a path expression, without walking objects by number.

Syntax

Delphi

Function TPDFlib.GetObjectByPath(Const Path: WideString; InfoID: Integer): WideString;

Parameters

PathThe path expression.
InfoID1 the type name (boolean, number, string, name, array, dict, stream, null); 2 the scalar value as text; 3 the serialised form, capped at 64 KB; 4 the key name when the last step selected a dictionary entry by index.

Return values

''The path does not resolve, or the value has no representation for the requested InfoID.
TextThe requested information.

Remarks

Path steps are /-separated dictionary keys starting at the trailer (Root/Pages/Kids[0]/MediaBox), with an optional trailer prefix and a pages[N] root that selects the 0-based N-th page dictionary. A 0-based [N] selector picks an array item or the N-th dictionary entry, and indirect references resolve at every step.

One call covers metadata probes, compliance spot checks and support diagnostics that previously required GetObjectToString plus hand-written parsing.

Example

W:= PDF.GetObjectByPath('Root/Pages/Kids[0]/MediaBox[2]', 2); // page width
T:= PDF.GetObjectByPath('pages[0]/Type', 2);                 // 'Page'

See also

GetObjectByPathCount, GetObjectToString, GetCatalogInformation