PDFiumVCL Docs

BookmarkFrom property

Ten wpis API zachowuje identyfikatory, sygnatury, bloki kodu i terminy PDF w oryginalnej postaci.
Component: TPdf  ·  Unit: PDFium
Converts a raw FPDF_BOOKMARK handle into a fully populated TBookmark record by reading the title, destination page, and action metadata for that outline node.

Syntax

property BookmarkFrom[Handle: FPDF_BOOKMARK]: TBookmark; // read only

Description

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.

Parameters

HandleFPDF_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.

Remarks

Example

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;

See Also

Bookmark, Bookmarks, BookmarkChildren, HasBookmarkChildren