-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature request: 'pdf_toc()' returns more pdf bookmarks information #117
Comments
In case it is helpful here is a minimal pdf document with the following pdf bookmarks features presents:
PDF attachment: bookmarks.pdf Note many open-source pdf viewers quietly ignore some of these features. Foxit reader is an example of a cross-platform (but proprietary) pdf reader that supports all of these. Here is the R code to create the minimal pdf with pdf bookmarks: library("grid")
library("grDevices")
library("xmpdf") # remotes::install_github("trevorld/r-xmpdf")
stopifnot(supports_gs()) # needs 'ghostscript'
# Create two-page pdf
pdf("bookmarks.pdf", onefile = TRUE)
grid.text("Page 1")
grid.newpage()
grid.text("Page 2")
invisible(dev.off())
# Add bookmarks
bookmarks <- data.frame(title = c("Front", "Page 1", "Page 2"),
page = c(1L, 1L, 2L),
count = c(2L, -1L, 0),
fontface = c("italic", "bold", "bold.italic"),
color = c("black", "red", "blue"))
set_bookmarks_gs(bookmarks, "bookmarks.pdf") Currently pdftools::pdf_toc("bookmarks.pdf") $title
[1] ""
$children
$children[[1]]
$children[[1]]$title
[1] "Front"
$children[[1]]$children
$children[[1]]$children[[1]]
$children[[1]]$children[[1]]$title
[1] "Page 1"
$children[[1]]$children[[1]]$children
$children[[1]]$children[[1]]$children[[1]]
$children[[1]]$children[[1]]$children[[1]]$title
[1] "Page 2"
$children[[1]]$children[[1]]$children[[1]]$children
list() |
I don't think poppler supports this right now, at least I can't find it in the API. I found this old post but it looks like it was never followed up on. |
Thanks for the explanation! Looking at the poppler API documentation I guess besides the bookmark's title the only other information the API makes available is whether that bookmark should start open/closed in the TOC (i.e. Feel free to close this issue but I'll leave it open since it seems you could still return the |
pdf_toc()
only returns the bookmark titles and the nesting hierarchy of bookmarks.pdftk
to get that information.The text was updated successfully, but these errors were encountered: