首页 > 解决方案 > Merging PDF easily with pdftools

问题描述

I'm doing several webscraping which returns daily pdf's in some directory (path) I need to find someway to get all files in as easy way. For now I'm listing all the files one by one. Is there an easy way to do it?

data_download
pdf_01 <- paste("path\\", data_download, " - MK - Debêntures novas.pdf", sep="")
pdf_02 <- paste("path\\", data_download, " - MK - Fundos novos.pdf", sep="")
pdf_03 <- paste("path\\", data_download, " - News - Instruções CVM.pdf", sep="")
pdf_04 <- paste("path\\", data_download, " - News - Notícias CVM.pdf", sep="")

pdf_merged <- paste("path\\", data_download, " - Novidades de hoje.pdf", sep="")

pdf_combine(c(pdf_01,pdf_02,pdf_03,pdf_04) ,output  = pdf_merged)

标签: rpdfmerge

解决方案


The function list.files() gets you most of the way to what you want, if you want all the files in your path folder that contain "pdf" in the name to be merged, you could do something like:

pdf_combine(list.files(path, pattern="pdf", full.names=TRUE), output  = pdf_merged)

推荐阅读