robflynn / pdftoimage

A ruby gem for converting pdfs to images.
MIT License
31 stars 23 forks source link

Is it possible to use remote url instead oflocal path? #2

Open mukul13 opened 2 years ago

mukul13 commented 2 years ago

Hi,

Thanks for creating this gem!

Question I have: Is it possible to use a remote url instead of local path?

images = PDFToImage.open("https://www.orimi.com/pdf-test.pdf")
# currently the above line is throwing an error. Is it possible to somehow pass this url as variable?
images.each do |img|
  img.save("page-#{img.page}.jpg")
end
louiswdavis commented 5 months ago

I've gotten around this by downloading/opening the external file to a Tempfile and using that temp path in the open method

file = URI.parse(remote_url).open

images = PDFToImage.open(File.expand_path(file.path))
images.each do |img|
  img.save("page-#{img.page}.jpg")
end