Rails PDF Plugin

This is one the the most simple and useful plugins you can use. To get started you will need to install the PDF::Writer gem.

gem install pdf-writer

Install the Rails PDF Plugin.

script/plugin install svn://rubyforge.org//var/svn/railspdfplugin/railspdf

To create a PDF document for an action, you need to change the action’s view extension from rhtml to rpdf. In the rpdf view you can insert PDF::Writer code. For example, to create a Hello, World PDF use just these two lines of code in the rpdf view:

pdf.select_font "Times-Roman"
pdf.text "Hello, #{@name}.",
  :font_size => 72, :justification => :center

Artima has a great article that covers in great detail the PDF::Writer library. With PDF::Writer you can create PDF documents with embedded images, business charts, tables, etc. With this plugin you can create PDF reports and documents from rails applications. You can create a PDF document for all of your blog posts.

Technorati Tags: , , , , , , ,

3 Responses to “Rails PDF Plugin”

Leave a Reply