Skip to content

Commit

Permalink
Add minimal Prawn example.
Browse files Browse the repository at this point in the history
  • Loading branch information
map7 committed Apr 29, 2010
1 parent 0b3cb9b commit cf5dc32
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions examples/pdf_table.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
$: << File.join(File.dirname(__FILE__), '..', 'lib')
require "ruport"

class Document < Ruport::Controller
stage :body

def setup
self.data = Ruport::Table(
:column_names => %w(Make Model Year),
:data => [
%w(Nissan Skyline 1989),
%w(Mercedes-Benz 500SL 2005),
%w(Kia Sinatra 2008)
])
end
end

class DocumentFormatter < Ruport::Formatter::PrawnPDF
renders :prawn_pdf, :for => Document

def build_body
draw_table(data)
end
end

Document.render(:prawn_pdf, :file => 'prawn_pdf.pdf')

0 comments on commit cf5dc32

Please sign in to comment.