
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
A Rails engine that provides PDF.js viewer functionality as a mountable engine. This gem allows you to easily integrate the PDF viewer from https://mozilla.github.io/pdf.js/ into your Rails application.
Add this line to your application's Gemfile:
gem 'pdfjs_viewer'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install pdfjs_viewer
Run the install generator to create a configuration file:
rails generate pdfjs_viewer:install
This will create config/initializers/pdfjs_viewer.rb
with all available configuration options.
Add this to your application's config/routes.rb
:
mount PdfjsViewer::Engine => "/pdf"
Edit config/initializers/pdfjs_viewer.rb
to customize which toolbar buttons are shown:
PdfjsViewer.configure do |config|
config.show_highlight_button = true # Show/hide highlight tool
config.show_text_button = true # Show/hide text annotation tool
config.show_draw_button = true # Show/hide drawing tool
config.show_add_edit_image_button = true # Show/hide image editing tool
config.show_print_button = true # Show/hide print button
config.show_save_button = true # Show/hide save/download button
config.show_open_file_button = true # Show/hide open file button
config.stylesheet_path = '/pdf.css' # Url path to override css file
end
Navigate to the viewer with a file parameter:
http://localhost:3000/pdfjs/viewer?file=https://example.com/sample.pdf
You can embed the viewer in your Rails views:
<iframe
src="<%= pdfjs_viewer_path %>?file=<%= CGI.escape(@pdf_url) %>"
frameborder="0" />
or you can use the object tag
<object
src="<%= pdfjs_viewer_path %>?file=<%= CGI.escape(@pdf_url) %>"
width="100%"
height="600px" >
<div>A fallback link/message if viewer does not load</div>
</object>
A helper pdfjs_viewer_path
is defined to return the path of the viewer
The viewer loads with default PDF.js styling. To customize the appearance, you can:
config.stylesheet_path
to a url path to a stylesheet in the initializer.
The viewer uses css variables that you can override in this css file.Run update script
bin/build_pdfjs $PDF_JS_VERSION
Script will replace the files in public/web
and public/build
. Any updates to viewer.html will need to be made manually in app/views/pdfjs_viewer/viewer/show.html.erb
. You can use the html file located at public/web/viewer.html
as a reference.
Afterwards commit and push changes.
Bug reports and pull requests are welcome on GitHub at https://github.com/primeroIMS/pdfjs-viewer.
This gem is available as open source under the terms of the Apache 2.0 License.
FAQs
Unknown package
We found that pdfjs_viewer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.