Skip to contents

These functions wrap around the utilities in the xmpdf package but alters the arguments to match this package's conventions: the first two arguments must be input and output, by default output = tempfile(fileext = ".pdf"), and all other arguments must be named.

Usage

pdf_set_bookmarks(input, output = NULL, ..., bookmarks)

pdf_set_docinfo(input, output = NULL, ..., docinfo)

pdf_set_xmp(input, output = NULL, ..., xmp)

Arguments

input

Input pdf filename.

output

Output pdf filename. NULL defaults to tempfile(fileext = ".pdf").

...

Currently ignored.

bookmarks

See xmpdf::set_bookmarks().

docinfo

See xmpdf::set_docinfo().

xmp

See xmpdf::set_xmp().

Value

output filename of new pdf file invisibly.

Examples

f1 <- pdf_create_blank(length = 2L)

if (requireNamespace("xmpdf", quietly = TRUE) &&
    xmpdf::supports_set_bookmarks()) {
  bm <- data.frame(title = c("Page 1", "Page 2"), page = c(1, 2))
  f2 <- pdf_set_bookmarks(f1, bookmarks = bm)
  unlink(f2)
}

if (requireNamespace("xmpdf", quietly = TRUE) &&
    xmpdf::supports_set_docinfo()) {
  di <- xmpdf::docinfo(title = "A Title", author = "The Author")
  f3 <- pdf_set_docinfo(f1, docinfo = di)
  unlink(f3)
}

if (requireNamespace("xmpdf", quietly = TRUE) &&
    xmpdf::supports_set_xmp()) {
  xmp <- xmpdf::xmp(title = "A Title", creator = "The Author")
  f4 <- pdf_set_xmp(f1, xmp = xmp)
  unlink(f4)
}
unlink(f1)