if (supports_set_docinfo() && supports_get_docinfo() && require("grid", quietly = TRUE)) {
f <- tempfile(fileext = ".pdf")
pdf(f, onefile = TRUE)
grid.text("Page 1")
grid.newpage()
grid.text("Page 2")
invisible(dev.off())
cat("\nInitial documentation info:\n\n")
d <- get_docinfo(f)[[1]]
print(d)
d <- update(d,
author = "John Doe",
title = "Two Boring Pages",
keywords = c("R", "xmpdf"))
set_docinfo(d, f)
cat("\nDocumentation info after setting it:\n\n")
print(get_docinfo(f)[[1]])
unlink(f)
}
Run the code above in your browser using DataLab