Skip to content

karmatr0n/rpdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

== RPDF Template Plugin for Ruby on Rails ==

A plugin to allow the inclusion of ruby code into your RPDF templates. This also enables you to use the *special* object called 'pdf' to use the methods of the pdf-writer gem.

Unlike conventional templates which are used to render the results of an action in html, these templates will be rendered as a pdf
document.

The rpdf templates end in .rpdf, for example: show.rpdf

Requirements:
gem install pdf-writer

== How to install ==

Installing as git-submodule:

$ cd your_rails_app
$ git submodule add git://github.com/alexjr85/rpdf.git vendor/plugins/rpdf

Installation with the plugin rails script:
$ cd your_rails_app
$ ./script/plugin install git://github.com/alexjr85/rpdf.git

== How to use ==

Edit your mime_types.rb initializer located under config/initializers and 
add the following line:
Mime::Type.register "application/pdf", :pdf

Example:

Edit your controller (app/controllers/people_controller.rb)
class PeopleController < ActionController
  def show
	@record = Person.find(:id)
	respond_to do |format|
	  	format.pdf { :render => 'show.rpdf' }
	end
  end
end

Edit your view (app/views/people/show.rpdf)

pdf.add_text(468, 671, @record.fullname, 10) # See for pdf-writer methods
j=0
@record.addresses.each do |address|
 pdf.add_text(85, 388 - 13*j, address.location, 10) #numeric order
 j += 1
end

== Credits ==

Alejandro Juarez <alexjr85@gmail.com>

About

Extension for ActionView::TemplateHandler class to support pdf rendering

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages