cat_pages | R Documentation |
cat_pages()
concatenates pdf documents together.
cat_pages(input, output)
cat_pages_gs(input, output)
cat_pages_pdftk(input, output)
cat_pages_qpdf(input, output)
input |
Filename(s) (pdf) to concatenate together |
output |
Filename (pdf) to save concatenated output to |
cat_pages()
will try to use the following helper functions in the following order:
cat_pages_qpdf()
which wraps qpdf::pdf_combine()
cat_pages_pdftk()
which wraps pdftk
command-line tool
cat_pages_gs()
which wraps ghostscript
command-line tool
The (output) filename invisibly.
supports_cat_pages()
, supports_gs()
, and supports_pdftk()
to detect support for these features.
cat_bookmarks()
for generating bookmarks for concatenated files.
if (supports_cat_pages() && require("grid", quietly = TRUE)) {
# Create two different two-page pdf files
make_pdf <- function(f, title) {
pdf(f, onefile = TRUE, title = title)
grid.text(paste(title, "Page 1"))
grid.newpage()
grid.text(paste(title, "Page 2"))
invisible(dev.off())
}
f1 <- tempfile(fileext = "_doc1.pdf")
on.exit(unlink(f1))
make_pdf(f1, "Document 1")
f2 <- tempfile(fileext = "_doc2.pdf")
on.exit(unlink(f2))
make_pdf(f2, "Document 2")
fc <- tempfile(fileext = "_cat.pdf")
on.exit(unlink(fc))
cat_pages(c(f1, f2), fc)
# Use `cat_bookmarks()` to create pdf bookmarks for concatenated output files
if (supports_get_bookmarks() && supports_set_bookmarks()) {
l <- get_bookmarks(c(f1, f2))
bm <- cat_bookmarks(l, "title")
set_bookmarks(bm, fc)
print(get_bookmarks(fc)[[1]])
}
unlink(f1)
unlink(f2)
unlink(fc)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.