0.01
No commit activity in last 3 years
No release in over 3 years
Viewerjs's images, stylesheets and javascript files packed here to be used with Rails
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
~> 10.0
 Project Readme

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

  • Only pdf can be viewed in browser for the time being. Once it becomes possible to load doc or odt file will package them here in this gem.