Returns a tibble row per bookmark, walking PDFium's outline tree depth-first. Each row carries the bookmark's title, its position in the hierarchy, the page it points to (when resolvable), and the action it carries (URI, launch, remote_goto, embedded_goto, or the typical goto-within-this-document).
Arguments
- doc
A
pdfium_docfrompdf_doc_open(), or a character path.
Value
A tibble with columns:
bookmark_indexinteger - 1-based pre-order index across the entire outline tree.parent_indexinteger -bookmark_indexof the parent entry, or0for top-level bookmarks.levelinteger - 1-based nesting depth.titlecharacter - the bookmark's display text, UTF-8.page_numinteger - 1-based destination page number, orNAwhen the bookmark has no resolvable page destination (e.g. for URI / launch actions, or unresolvable dests).action_typecharacter - one of"goto","remote_goto","uri","launch","embedded_goto".uricharacter - the action's target URL whenaction_type == "uri";NAotherwise.filepathcharacter - the external file path whenaction_typeis"remote_goto"/"launch"/"embedded_goto";NAotherwise.dest_viewcharacter - the destination view mode (one of"xyz","fit","fith","fitv","fitr","fitb","fitbh","fitbv","unknown").dest_x,dest_y,dest_zoomnumeric - the explicit point / zoom for XYZ destinations and the line offset for FitH / FitV / FitBH / FitBV.NAfor components the destination doesn't specify.
Returns a 0-row tibble of the same schema when the document has no outline.
Details
The tree structure is recoverable from the parent_index column
alone: top-level bookmarks have parent_index == 0, and every
other bookmark's parent is the row whose bookmark_index matches
its parent_index. The level column is a convenience for
filtering ("show me chapter-level entries only").
Wraps FPDFBookmark_GetFirstChild, FPDFBookmark_GetNextSibling,
FPDFBookmark_GetTitle, FPDFBookmark_GetDest,
FPDFBookmark_GetAction, FPDFAction_GetType /
FPDFAction_GetURIPath / FPDFAction_GetFilePath, and
FPDFDest_GetDestPageIndex.
See also
pdf_page_labels() for logical page numbering,
pdf_page_links() for clickable link annotations on a page.
Examples
fixture <- system.file("extdata", "fixtures", "outline.pdf",
package = "pdfium"
)
if (nzchar(fixture)) pdf_doc_bookmarks(fixture)
#> # A tibble: 3 × 12
#> bookmark_index parent_index level title page_num action_type uri filepath
#> <int> <int> <int> <chr> <int> <chr> <chr> <chr>
#> 1 1 0 1 Chapter… 1 goto NA NA
#> 2 2 1 2 Section… 1 goto NA NA
#> 3 3 1 2 Section… 2 goto NA NA
#> # ℹ 4 more variables: dest_view <chr>, dest_x <dbl>, dest_y <dbl>,
#> # dest_zoom <dbl>