praveenkumarsinha / viewerjs-rails

MIT License
4 stars 11 forks source link

Viewerjs::Rails

This gem packages the Viewerjs assets (JavaScripts, stylesheets, and images) for the Rails asset pipeline, so you never have to download a custom package through the web interface again.

See VERSIONS.md to see which versions of viewerjs-rails bundle.

Installation

Add this line to your application's Gemfile:

gem 'viewerjs-rails'

And then execute:

$ bundle

Or install it yourself as:

$ gem install viewerjs-rails

Usage

Load viewerjs from rails assets manifest file. Add the following to your application.js:

//= require viewerjs_rails

Add the following to your application.css:

/*
 *= require viewerjs_rails
 */

Add helper to embed blank viewer in specific controller's view:

  <%= viewerjs_viewer %>
  <%= viewerjs_viewer(viewer_alignment: 'left') %>
  <%= viewerjs_viewer(title: 'Some title') %>
  <%= viewerjs_viewer({viewer_alignment: 'right', title: 'Some title'}) %>

And visit the page with static pdf path in reference after #. Please note that changing pdf path after # in url will not refresh the page (from its current content) so better to add some random querystring or do hard reset like (Ctrl+F5 or Command+R):

http://localhost:3000/#test.pdf
http://localhost:3000/?1=2#test.pdf

Contributing

  1. Fork it ( https://github.com/praveenkumarsinha/viewerjs-rails/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Limitations