Plugin details

A rails plugin leveraging the new prawn library to produce compiled pdf views

Websitehttp://cracklabs.com/prawnto Repositorygit://github.com/thorny-sun/prawnto.git Author thorny-sun Tags prawn, PDF LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install git://github.com/thorny-sun/prawnto.git

Initial Assumptions / Requirements
============================
you are running rails >= 2.1
you have been git-assimilated
you've set up a rails app and git-init'ed it

Getting Started
===============
pull in prawnto plugin
---------------------------

git submodule add \
  git://github.com/thorny-sun/prawnto.git \
  vendor/plugins/prawnto



pull in prawn library
----------------------------
if you desire stability:

gem install prawn


or if you want the latest greatest:
------------------------------------------

git submodule add \
  git://github.com:sandal/prawn.git \
  vendor/gems/prawn-0.1.0.1/


set up gem dependency
----------------------------------
insert line into environment.rb at appropriate place

config.gem "prawn"


Ideally I could remove this step by getting the plugin to register the dependency on its own, but i couldn't figure out how. Please tell me if you know. init.rb seems to be too late in the initialization process to work.

create your view
------------------------
give your filename a .pdf.prawn extension and then just code your view using the pdf Prawn::Document object

@prawn_document_options
======================
If you'd like to set any of the Prawn::Document initial setup options, then you will have to set them up in the controller using the @prawn_document_options hash. For example:

@prawn_document_options = {:page_layout=>:landscape}In addition to the normal prawn options, you may also specify any of these prawnto options: 



:attachment
controls whether the pdf gets downloaded as an attachment or whether it is viewed inline within the browser. false by default.

:filename
filename associated to pdf. defaults to the name given by the url.


Gotchyas
============
layouts
------------
don't forget to disable where necessary if you don't want them futzing with your '.pdf.prawn' views, unless of course you're using a layout on purpose

View/Controller Boundary
=======================
Ideally the view stuff would be specified in the view. Prawn now includes a :skip_page_creation option that can fascilitate this somewhat. To pursue this ideal, you could set @prawn_document_options = {:skip_page_creation=>:true} in the controller constructor. And then remember to explicitly start a page in the view with pdf.start_new_page(options).

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, 4 months ago