Description Usage Arguments Details Value Note Author(s) See Also Examples
This function combines Portable Document Format (PDF) files into a single new PDF file.
1 |
path |
character. Path name of the folder containing the PDF files to merge. |
pdfs |
character.
Vector of file names, if missing, all PDF files under |
preserve.files |
logical. If true, all individual PDF files are preserved after a merge is completed. |
open.file |
logical. If true, the merged PDF file is opened using your systems default PDF viewer. |
Names of the individual PDF files are used as bookmarks in the merged file.
The merged file is placed one directory above the path
folder.
Returns the name of the merged file.
Requires PDFtk Server, a cross-platform command-line tool for working with PDFs.
J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # Create a temporary directory
dir.create(path <- file.path(tempdir(), "merge"))
# Write three single-page PDF files to the temporary directory
pdf(file.path(path, "f1.pdf"))
plot(seq_len(10), main = "f1a")
plot(sin, -pi, 2 * pi, main = "f1b")
plot(qnorm, col = "red", main = "f1c")
dev.off()
pdf(file.path(path, "f2.pdf"))
plot(table(rpois(100, 5)), type = "h", col = "yellow", main = "f2a")
dev.off()
pdf(file.path(path, "f3.pdf"))
plot(x <- sort(rnorm(47)), type = "s", col = "green", main = "f3a")
plot(x, main = "f3b")
dev.off()
# Merge PDF files into a single file and open it in your default viewer
MergePDFs(path, open.file = TRUE)
# Remove PDF files
unlink(path, recursive = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.