property BookmarkFrom[Handle: FPDF_BOOKMARK]: TBookmark; // read only
BookmarkFrom is the bridge between low-level PDFium bookmark traversal and the high-level TBookmark record. Whenever you obtain an FPDF_BOOKMARK handle directly from PDFium (for example through FPDFBookmark_GetFirstChild, FPDFBookmark_GetNextSibling, or as part of a click hit-test in a viewer), pass it through this indexer to receive the resolved title text, the target PageNumber, the TPdfAction kind, and any associated URI / file path.
The returned record is a snapshot: it reads the bookmark dictionary once and decodes the destination into a 1-based page number. The handle itself is also stored on the record so you can pass it back into PDFium APIs without another tree walk.
This indexer is the canonical way to implement a custom outline traversal that needs more control than Bookmarks (which enumerates everything depth-first) or BookmarkChildren (which only returns direct children). Mix raw PDFium handles with BookmarkFrom resolution to build, for instance, a lazy-load tree view.
| Handle | FPDF_BOOKMARK. A non-nil bookmark handle obtained from the PDFium C API or from a previous TBookmark.Handle field. Passing nil returns a zero-filled record. The handle remains valid only while the underlying document is loaded. |
TBookmark record — do not call any PDFium release function on it. PDFium frees outline handles automatically when the document closes.Action field uses the same TPdfAction enum as Bookmark and LinkAnnotation, so the same dispatcher code can route clicks from outline entries and link annotations alike.PageNumber is reported as 0. Use HasBookmarkChildren to decide whether to expand or navigate.
procedure TForm1.DumpOutline(const Bm: TBookmark; Depth: Integer);
var
Child: FPDF_BOOKMARK;
Sub: TBookmark;
begin
Memo1.Lines.Add(StringOfChar(' ', Depth * 2) + Bm.Title +
Format(' -> page %d', [Bm.ActionPageNumber]));
Child := FPDFBookmark_GetFirstChild(Pdf1.Document, Bm.Handle);
while Child <> nil do
begin
Sub := Pdf1.BookmarkFrom[Child];
DumpOutline(Sub, Depth + 1);
Child := FPDFBookmark_GetNextSibling(Pdf1.Document, Child);
end;
end;