Skip to content
A simple Rails wrapper for the PrinceXML PDF generation library.
Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib Bump to v2.1.0 Aug 1, 2017
spec Added support to Rails 5, Fixed rspec tests and installed princexml i… Jan 19, 2017
.gitignore
.rspec Decouple Princely a little more from Rails Jan 11, 2013
.travis.yml
Gemfile Added support to Rails 5, Fixed rspec tests and installed princexml i… Jan 19, 2017
MIT-LICENSE Initial import of Princely. Dec 17, 2007
README.md
Rakefile Re-added bundler gem tasks Oct 17, 2013
princely.gemspec Update gem to 2.0.2 Jun 16, 2016

README.md

Princely

Princely is a simple wrapper for the Prince XML PDF generation library. The plugin will also automatically register the PDF MimeType so that you can use pdf as a format in Rails controller respond_to blocks.

Example

class Provider::EstimatesController < Provider::BaseController
  # You can render PDF templates simply by
  # using the :pdf option on render templates.
  def show
    respond_to do |format|
      format.html
      format.pdf do
        render :pdf => 'file_name',
               :template => 'controller/action',
               :handlers => %w[erb],
               :formats => %w[pdf],
               :stylesheets => %w[application prince],
               :layout => 'pdf',
               :locals => { :foo => 'bar' },
               :disposition => 'inline', # PDF will be sent inline, means you can load it inside an iFrame or Embed
               :relative_paths => true # Modify asset paths to make them relative. See [the AssetSupport module](/lib/princely/asset_support.rb)
      end
    end
  end

  # Alternatively, you can use make_and_send_pdf to render out a PDF for the
  # action without a respond_to block.
  def pdf
    make_and_send_pdf "file_name"
  end
end

Render Defaults

The defaults for the render options are as follows:

layout:          false
template:        the template for the current controller/action
locals:          none
stylesheets:     none
disposition:     attachment (created PDF file will be sent as download)
relative_paths:  true
server_flag:     true
javascript_flag: false
timeout:         none

Contributors

Resources

  • Copyright (c) 2007-2013 Michael Bleigh and Intridea, Inc., released under the MIT license.
You can’t perform that action at this time.