documentcloud / docsplit

Break Apart Documents into Images, Text, Pages and PDFs
http://documentcloud.github.io/docsplit/
Other
831 stars 214 forks source link

How to use with paperclip? #25

Closed shlomizadok closed 13 years ago

shlomizadok commented 13 years ago

Hi, First, Docsplit is awesome. Thank you for sharing that. I would like that my users will upload a file (pdf) and that they will have it available as images. I am trying to combine paperclip with docsplit for that with no real success (Rails newbie).

Any tips / directions on how can I accomplish that? How did you do it on documentcloud?

Thank you so much! S.

textmaster commented 12 years ago

any luck achieving that ? I am looking for something similar ?

shlomizadok commented 12 years ago

yeah. I did something like: I have created an uploader -->

class PresentationUploader < CarrierWave::Uploader::Base

  include Studyers::Docsplit
  # Choose what kind of storage to use for this uploader:
  storage :file
  #storage :fog

  # Override the directory where uploaded files will be stored.
  # This is a sensible default for uploaders that are meant to be mounted:
  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end

  process :extract_images
end

and in the Studyers/docsplit.rb:

def extract_images
  ::Docsplit.extract_images(current_path, :size => %w{1000x}, :format => :png, output: output_path)
  self
end

private
  def output_path
    "public/#{store_dir}"
  end
textmaster commented 12 years ago

thx :)