0

I have tried exploring pdftools. It does have a pdf_combine() function which stitches multiple pdf to one. However, It doesn't help combine multiple pages of a pdf document into one page.

1 Answers1

0

If you want to combine a subset of pages, you could use the pdftools library and the pdf_split command. First, split the original PDF and save the result to your working directory. Then, you could make a list of the split files with list.files and recombine them in the same directory with a new name.

library(pdftools)
setwd("Z:/mypath/folder")  # put all your PDFs here; initially to include one file that is to be split
pdf_split('originalfile.pdf') # split pages into multiple files
myfiles<-list.files(pattern = "pdf")  # get a list of the split files
myfiles<-myfiles[1:4]  # select the first four pages, for example
pdf_combine(myfiles,output = "joined.pdf")  # join them
Ben
  • 1,113
  • 10
  • 26
  • This isn't what the OP was asking for. I believe they wanted the images on a single sheet, not multiple sheets within one PDF. I found a work around whereby I created my intermediary images as .png files and then combined them using the method described here [link](https://stackoverflow.com/questions/28682712/how-to-merge-images-into-one-file-in-a-defined-order). – JamesF Jul 26 '22 at 15:10