GetPageFontID
Fonts, page properties
Description
Returns the object number of the Index-th font resource on the given page, counted in the order in which the page's font dictionary lists them, and restores the previously selected page afterwards. Returns 0 when no document is open or either argument is out of range.
Syntax
Delphi
Function TPDFlib.GetPageFontID(Page, Index: Integer): Integer;
Parameters
Page is the 1-based page number and must lie in 1..PageCount; it need not be the page that is currently selected, because the function selects it internally and restores the previous selection before returning. Index is the 1-based position of the entry inside that page's /Resources /Font dictionary, so it must lie in 1..GetPageFontCount for the same page.
Return values
The object number of the Index-th font dictionary, that is the number which identifies the dictionary inside the PDF file and which the low-level object readers such as GetObjectToString and GetObjectJSON accept; it is not a font ID and cannot be passed to SelectFont. The result is 0 when Page or Index is out of range, when the page carries no /Font resource dictionary, or when the entry is not an indirect object, and since object numbers start at 1 a zero always means failure.
Remarks
Only the /Resources entry stored on the page dictionary itself is inspected, so a font resource inherited from an ancestor page-tree node is reported only once the library has materialised that resource dictionary on the page, and an inherited set that has not been materialised yet yields 0 for every index. Entries are reported in dictionary order and are not deduplicated: the same font listed under two resource names returns the same object number twice. Enumerate 1..GetPageFontCount to walk every font of the page, and prefer FindFonts or EnumDocumentFonts when a document-wide inventory with base font, embedding state and encoding is wanted instead of object numbers.