Closed aalvrz closed 6 years ago
what does come from puts pages.inspect
?
@shairontoledo
This:
["/tmp/17879240-349300-1506537028_0002.jpeg", "/tmp/17879240-349300-1506537028_0001.jpeg"]
You can see that it is an array of strings:
> pages.first.class
=> String
Try to rename the file like:
range = 5..6
pages = RGhost::Convert.new('/tmp/test.pdf').to :jpeg, multipage: true, range: range
dest_dir = "/your/dir/here/"
files = range.to_a.zip(pages).map do |page_number, filename|
dest_file = "#{dest_dir}/page_#{page_number}.jpeg"
FileUtils.mv(filename, dest_file)
File.open(dest_file)
end
@shairontoledo Seems like a very cumbersome way of achieving this.
I am following this Wiki page to convert a PDF file to multiple images. However, I am seeing a few strange things on the way that rghost works.
For example, according to the Wiki, the following command will return an array of
File
objects:Yet I get an array of strings instead while the converted files get generated in my
/tmp/
directory.I am trying to find a way to specify the name of each file converted that gets created and where to put it in my file system, yet I can't find a way to do this in the Wiki. Can you help me?