0

I am trying to arrange plots from pdf to a single plot as grid. Here is the code and error:

pdffiles <-
  list.files(
    path = here::here("/Users/test/"),
    recursive = TRUE,
    pattern = "\\.pdf$",
    full.names = T
  )

magick::image_read_pdf(pdffiles) %>%
  magick::image_montage(tile = "2x5", geometry = "x500+10+5") %>%
  magick::image_write(
    format = ".pdf", path = here::here(paste(name,"_All.pdf",sep="")),
    quality = 100
  )
Error in file(con, "rb") : invalid 'description' argument
In addition: Warning messages:
1: In if (is_svg(path)) return(path) :
  the condition has length > 1 and only the first element will be used
2: In if (is_url(path)) { :
  the condition has length > 1 and only the first element will be used
3: In if (grepl("^[^/\\]+:($|[^/\\])", path)) { :
  the condition has length > 1 and only the first element will be used

Can anyone help?

Thanks!

Rdu U
  • 57
  • 4
  • 1
    This might help... https://stackoverflow.com/questions/74660260/r-pdftools-combine-multiple-pages-into-a-single-page/74719825#74719825 – Andrew Gustar Dec 16 '22 at 17:07
  • Thank you so much!!!! @Andrew Gustar - How to retain bold fonts and add titles to individual image? – Rdu U Dec 16 '22 at 18:28
  • original file has bold fonts – Rdu U Dec 16 '22 at 18:29
  • I tried to image annotate but it adds title to just the first one and ignores the rest – Rdu U Dec 16 '22 at 18:34
  • It is just manipulating the images, so it shouldn't change the fonts. It might just be because everything is smaller that it loses the effect??? – Andrew Gustar Dec 16 '22 at 19:19
  • Ahh yeah that could be the reason. makes sense! Apologies for too many questions? one last thing is how do I add file names as title using image_annotate? – Rdu U Dec 16 '22 at 19:31
  • I've never used image_annotate, but I would perhaps try to do it at the reading in stage - e.g. `pdfs <- Reduce(c, lapply(files, function(file) image_annotate(image_read_pdf(file), file, location, size)))` or something along those lines. Have a look at the documentation and perhaps ask another question here if you still need help. Good luck! – Andrew Gustar Dec 16 '22 at 22:42

0 Answers0