public
Fork of mbleigh/princely
Description: A simple Rails wrapper for the PrinceXML PDF generation library.
Homepage: http://www.mbleigh.com/plugins/princely-rails-prince-xml-wrapper
Clone URL: git://github.com/drnic/princely.git
Jack Chen and Dr Nic Williams (author)
Thu Oct 01 23:00:30 -0700 2009
commit  c0fe257f566224af7fdae0364c4cc53bc39b5995
tree    2104eba0b88fd3c6ad2856c10f23a270dd1e44d9
parent  91b6585ee7a346f30ffbea0ae667076973ed9a90
name age message
file .gitignore Thu Aug 20 21:10:47 -0700 2009 added 1.0.0 gemspec [drnic]
file MIT-LICENSE Mon Dec 17 07:55:59 -0800 2007 Initial import of Princely. git-svn-id: http... [michael]
file README.md Thu Aug 20 21:13:33 -0700 2009 bullet pointing the licenses [drnic]
file Rakefile Thu Aug 20 21:09:55 -0700 2009 gemified this project with jeweler for github r... [drnic]
file VERSION Wed Sep 30 18:09:35 -0700 2009 Version bump to 1.2.4 [drnic]
file init.rb Thu Aug 20 22:01:54 -0700 2009 fixed the path to the rails initialiser [drnic]
directory lib/ Thu Oct 01 23:00:30 -0700 2009 bumped the version and allow passing in additio... [Jack Chen and Dr Nic Williams]
file princely.gemspec Thu Oct 01 23:00:30 -0700 2009 bumped the version and allow passing in additio... [Jack Chen and Dr Nic Williams]
README.md

Princely

Princely is a simple wrapper for the Prince XML PDF generation library (http://www.princexml.com). It is almost entirely based on the SubImage Prince library found on this blog post:

http://sublog.subimage.com/articles/2007/05/29/html-css-to-pdf-using-ruby-on-rails

I have taken the helpers and made them a little bit more generalized and reusable, and created a render option set for pdf generation. The plugin will also automatically register the PDF MimeType so that you can use pdf in controller respond_to blocks.

Example

class Provider::EstimatesController < Provider::BaseController
  def show
    respond_to do |format|
      format.html
      format.pdf do
        render :pdf => "file_name", 
               :template => "controller/action.pdf.erb", 
               :stylesheets => ["application","prince"]
               :layout => "pdf"
      end
    end
  end

  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
stylesheets: none

Resources

  • Copyright (c) 2007 Michael Bleigh and Intridea, Inc., released under the MIT license
  • Copyright (c) 2007 Seth from Subimage from http://sublog.subimage.com/2007/05/29/html-css-to-pdf-using-ruby-on-rails