This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
prawn-handler / README.mdown
Prawn-handler
A Rails template handler for PDF library Prawn. You can find a more detailed description in its introduction article.
There already exists prawnto but it's too bloated for my taste. Prawn-handler is lightweight, simple, and less of a hassle to use.
Installation
script/plugin install git://github.com/Roman2K/prawn-handler.git
Usage
Declare the PDF MIME type in an initializer or
environment.rb:Mime::Type.register "application/pdf", :pdfName PDF view files like
foo.pdf.prawn. Inside, use thepdfmethod to access aPrawn::Documentobject. In addition, this handler allows for lazy method calls: you don't have to specify the receiver explicitely, which cleans up the resulting view code.For example, the following code with formal calls:
pdf.bounding_box [100, 600], :width => 200 do pdf.text "The rain in spain falls mainly on the plains " * 5 pdf.stroke do pdf.line pdf.bounds.top_left, pdf.bounds.top_right pdf.line pdf.bounds.bottom_left, pdf.bounds.bottom_right end endIs equivalent to this one with lazy calls:
This is accomplished withoutbounding_box [100, 600], :width => 200 do text "The rain in spain falls mainly on the plains " * 5 stroke do line bounds.top_left, bounds.top_right line bounds.bottom_left, bounds.bottom_right end endinstance_eval, so that access to instance variables set by the controller is retained.
Credits
Written by Roman Le Négrate (contact). Released under the MIT-license: see the LICENSE file.







