Convert PDF pages to JPEGs using R

I often get PDFs which have interesting images in them, but the problem is how to extract them?
This R Code will find every PDF in the current folder and covert each page to a 200 dpi JPEG

library(tidyverse)
library(pdftools)
library(fs)

# Uses the fs library to list all files ending in PDF in the current directory and store them in file_list

file_list <- dir_ls(glob = "*.pdf")

# The eqivualent of a FOR loop, it iterates through each element of file_list and converts each PDF page to a 200dpi jpg using the pdftools library
lapply(file_list, FUN = function(files) {
  pdf_convert(files, format = "jpeg",dpi = 200)
})

# https://stackoverflow.com/questions/49941158/how-do-i-pull-in-multiple-pdfs-into-pdf-convert-using-r-and-pdftools-package

Leave a Reply

Your email address will not be published. Required fields are marked *