title: Rails 5 pdf preview with Shrine Gem
body: <p>I am using <a href="http://shrinerb.com/" rel="nofollow noreferrer">Shrine Gem</a> for image uploads and was wondering how, if possible, can I show a 1st page preview in my template like showing an image per-say.  I am ok with using jQuery or other library.  Below is my code for the file upload, including my Shrine initializer and uploader file. </p>
  
  <p><strong>view</strong></p>
  
  <pre><code>...
  &lt;div class="col-md-4 upload-block"&gt;
      &lt;%= f.label :spec_sheet, 'Spec Sheet' %&gt;
        &lt;% if @product.spec_sheet.present? %&gt;
          &lt;div class="product-image"&gt;
            &lt;%= image_tag(@product.spec_sheet_url(:thumb)) %&gt;
              &lt;div class="input-checkbox input-checkbox--switch"&gt;
                &lt;input name="product[remove_spec_sheet]" type="hidden" value="0"&gt;
                &lt;input id="checkbox-switch" type="checkbox" name="product[remove_spec_sheet]"&gt;
                &lt;label for="checkbox-switch"&gt;&lt;/label&gt;
              &lt;/div&gt;
              &lt;span&gt;Remove Spec Sheet&lt;/span&gt;
          &lt;/div&gt;
          &lt;% end %&gt;
            &lt;%= f.hidden_field :spec_sheet, value: @product.cached_spec_sheet_data %&gt;
              &lt;%= f.file_field :spec_sheet %&gt;
    &lt;/div&gt;
  ...
  </code></pre>
  
  <p><strong>initializer</strong></p>
  
  <pre><code>require 'shrine'
  require 'shrine/storage/file_system'
  
  Shrine.storages = {
      cache: Shrine::Storage::FileSystem.new('public', prefix: 'uploads/cache'),
      store: Shrine::Storage::FileSystem.new('public', prefix: 'uploads/store'),
  }
  
  Shrine.plugin :activerecord
  Shrine.plugin :remove_attachment
  Shrine.plugin :delete_raw
  Shrine.plugin :cached_attachment_data # for forms 
  </code></pre>
  
  <p><strong>uploader</strong></p>
  
  <pre><code>require 'image_processing/mini_magick'
  class ImageUploader &lt; Shrine
    MAX_IMAGE_SIZE_MB = 5
    include ImageProcessing::MiniMagick
  
    plugin :determine_mime_type
    plugin :remove_attachment
    plugin :store_dimensions
    plugin :validation_helpers
    plugin :processing
    plugin :versions
    plugin(:default_url) { |_|  '/img/preview-not-available.jpg' }
  
    Attacher.validate do
      validate_max_size MAX_IMAGE_SIZE_MB.megabytes, message: "is too large (max is #{MAX_IMAGE_SIZE_MB} MB)"
      validate_mime_type_inclusion %w[image/jpeg image/jpg image/png image/gif]
    end
  
    process(:store) do |io|
      original = io.download
  
      size_1500 = resize_to_limit!(original, 1500, 600)
      size_500 = resize_to_limit(size_1500,  500, 500)
      size_300 = resize_to_limit(size_500,  300, 300)
  
      {original: size_1500, medium: size_500, thumb: size_300 }
    end
  end
  </code></pre>