github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

Roman2K / prawn-handler

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 18
    • 0
  • Source
  • Commits
  • Network (0)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Rails template handler for PDF library Prawn — Read more

  cancel

http://roman.flucti.com/alternative-prawn-handler-for-rails

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

fixed a typo in the README 
Roman2K (author)
Sun Mar 15 13:19:35 -0700 2009
commit  f657b156ddd8c2fdc07c172165a9f4d391cd73ad
tree    279bac6659b6aced352f22d5dacc7144c17c11d8
parent  b91764011d1ac4939166b69d456e1685380414b2
prawn-handler / README.mdown README.mdown
100644 44 lines (28 sloc) 1.871 kb
edit raw blame history

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

  1. Declare the PDF MIME type in an initializer or environment.rb:

    Mime::Type.register "application/pdf", :pdf
    
  2. Name PDF view files like foo.pdf.prawn. Inside, use the pdf method to access a Prawn::Document object. 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
    end
    

    Is equivalent to this one with lazy calls:

    bounding_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
    end
    
    This is accomplished without instance_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.

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server