PDF to PNG Processor - Paperclip
- by Josh Crowder
I am trying to develop a system in which a user can upload a slideshow
(pdf) and it'll export each slide as a png. After some digging around
I came across a post on here that suggested using a processor. I've
had a go, but I cant get the command to run, if it is running then I
don't know what is happening because no errors are being shown. Any
help would be appreciated!
module Paperclip
class Slides < Processor
def initialize(file, options = {}, attachment = nill)
super
@file = file
@instance = options[:instance]
@current_format = File.extname(@file.path)
@basename = File.basename(@file.path, @current_format)
end
def make
dst = Tempfile.new( [ @basename, @format].compact.join("."))
dst.binmode
command = <<-end_command
-size 640x300
#{ File.expand_path(dst.path) }
tester.png
end_command
begin
success = Paperclip.run("convert", command.gsub(/\s+/, " ")))
rescue PaperclipCommandLineError
raise PaperclipError, "There was an error processing the
thumbnail for #{@basename}"
end
end
end
end
I think my problem is with the convert command... When I run that command by hand, it works but it doesn't give the details of each slide it just executes it. What I need to happen is once its made all the slides, pass back the data to a new model... or I know where all the slides are, but once I get to that point I'm not sure what todo.