Merging existing PDF files using R
pdf, r
Solution
For an R-based solution which doesn't rely on calling the underlying OS with `system()` or `system2()`, I would recommend the {qpdf} package.
You may install this package as:
install.packages("qpdf")
You'll then want to make use of the `pdf_combine()` function. Check its documentation as:
?qpdf::pdf_combine
You can then merge as many pdfs as you like. Here I merge `file.pdf`, `file2.pdf` and `file3.pdf` into a new file called `output.pdf`:
qpdf::pdf_combine(input = c("file.pdf", "file2.pdf", "file3.pdf"),
output = "output.pdf")
Problem
I want to merge PDF files that already exist (already saved in my computer) using R. I already tried to use open source softwares to merge them and it works fine but since I have a couple hundreds of files to merge together, I was hoping to find something a little faster (my goal is to have the file automatically created - or updated, simply by running an R command). I am used to R so I would like to find a way to create this new multiple-sheet PDF using this program. Is there any function that could do that for me? Thanks!