i have a dataset that contains column for ID and one for their URL to download, each ID has 2 URLS,
i want to download each two URLS and convert them to one PDF file named with their ID.
i want one PDF for each ID.
# demo dataset
df <- data.frame(ID = c(1,1,2,2,3,3),
Full_Path = c("https://test1.png","https://test1.png",
"https://test1.png","https://test1.png",
"https://test1.png","https://test1.png"))
for (url in df$Full_Path) {
download.file(url, destfile = basename(url), method="curl", extra="-k", mode="wb")
fl = list.files(full.names = T, pattern = '.png')
img = image_read(fl) # read from vector of paths
img2 = image_append(img, stack = TRUE) # places pics above one another
image_write(img2, format="pdf", file.path(dir,paste('IMG',today(),'.pdf')))
}
unlink(fl)