The function bellow has been kindly provided by @Tyler Rinker and can be found here
Function I'm struggling with:
mergePDF <- function(..., file, gsversion = NULL, in.file = NULL) {
if (is.null(in.file)) {
in.file <- substitute(...())
}
infiles <- paste(unlist(lapply(file.folder, function(y) as.character(y))),
collapse = " ")
if (is.null(gsversion)) {
gsversion <- names(which(Sys.which(c("gswin64c")) != paste("C:/Program Files/gs9.15/bin/gswin64c.exe",sep="")))
}
pre = " -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="
system(paste(paste(gsversion, pre, file, sep = ""), infiles, collapse=""))
}
I would like to bind (combine) multiple existing pdf file into 1 pdf file. I have multiple files named according to id
for example: doc_123232.pdf, doc_434324.pdf etc.
How to set the in.file
?
Ideally, I would like to set only the folder where the files are stored: something like: Sys.glob("C:/Path/doc*.pdf")
EDIT: I have tried it for now only with 1 pdf page I have, not for multiple files:
mergePDF(file="C:/1pagepdf.pdf",in.file="C:/path/doc_123232.pdf")
I'm getting error: had status 127
==> clearly I don't understand the parameter in.file