ruby on rails - Minimagick gem fails to convert multipage PDF to several png images -
i new ror , i'm trying develop slide sharing app through users can upload , share multipage pdfs containing deck of slides (one slide per page). viewers can view these slides on "show" page.
behind scenes trying convert multipage pdf several .png files (1 pdf page -> 1.png file), , display them in carousel/slider fashion.
here uploader:
# encoding: utf-8 class docuploader < carrierwave::uploader::base # include rmagick or minimagick support: # include carrierwave::rmagick include carrierwave::minimagick # choose kind of storage use uploader: storage :file # storage :fog # override directory uploaded files stored. # sensible default uploaders meant mounted: def store_dir # 'public/doc_uploads/' "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end process :filename process :generate_png def generate_png pdf = minimagick::image.new(self.file.path) pdf.pages.each_with_index |page, index| page.write("page#{index}.png") end end # add white list of extensions allowed uploaded. # images might use this: def extension_white_list %w(pdf) end # override filename of uploaded files: # avoid using model.id or version_name here, see uploader/store.rb details. def filename 'doc.pdf' if original_filename end end
when try upload multipage pdf document, throws me error: 'identify /public/uploads/tmp/1443619784-406-3861/doc.pdf' failed error:
@ line pdf.pages.each_with_index |page, index|
i have tried different solutions converting document, none of them have worked me far. why run of mill .pdf file fail minimagick's validation? there can avoid running issue? advice appreciated!
Comments
Post a Comment