I try to output the 1st page of pdf to png using “pdf_convert” function present in pdftools-library. I get the png but the output file name having "image(page number).png". how to get the output file exactly same to the input file name Pdf name:- beer&cider_2bay_x_4shelf_londis_cluster1.pdf Png name:- beer&cider_2bay_x_4shelf_londis_cluster1_1.png
How get output file name exactly same to input file name in R. what should be filename formating in pdfconverter in R
676 Views Asked by piya ingole At
2
There are 2 best solutions below
0

The 'pdftools' package info is avaliable at https://docs.ropensci.org/pdftools and https://github.com/ropensci/pdftools#readme.
library(pdftools)
pdf_convert("Some/file/path/filename.pdf",
format = "png",
pages = 1, # use page number
filenames = "filename" # Set output file name
)
This will generate the file in your working directory.
Save the [png] to a specific folder using full file path or here::here()
Adapt this code for your needs to extract all images needed from a pdf to a specific folder in
png
with the same name as the original pdf file: