title: Preview of PDF while using Minimagick and Carrierwave in Rails
body: <p>I've been trying to develop a site that allows for the uploading of various types of documents including pdfs. Below is my uploader:</p>
  
  <pre><code>class PictureUploader &lt; CarrierWave::Uploader::Base
  include CarrierWave::MiniMagick
  
  def store_dir
   "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end
  
  version :jpg do
   process :convert_to_images
   process :set_content_type_jpg
  
  def convert_to_images(*args)
   image = MiniMagick::Image.open(current_path)
   image.pages.each_with_index do |page, index|
    MiniMagick::Tool::Convert.new do |convert|
     convert.background 'white'
     convert.flatten
     convert.density 300
     convert.quality 95
     convert &lt;&lt; page.path
     convert &lt;&lt; "#{CarrierWave.root}/#{store_dir}/image-#{index}.jpg"
    end
   end
  end
  end        
  
  def set_content_type_jpg(*args)
  self.file.instance_variable_set(:@content_type, "image/jpg")
  end
  
  def extension_whitelist
    %w(jpg jpeg gif png pdf)
  end
  
  end
  </code></pre>
  
  <p>So far the site will allow uploads to the server of all of the whitelisted file types, and everything but pdfs will actually display. Pdfs, however, will only show a broken image rather than an image of that pdf. What can I do to fix this?</p>