class Prawn::Document
Public Instance Methods
flexible_table(data, options={})
click to toggle source
Builds and renders a Document::FlexibleTable object from raw data. For details on the options that can be passed, see Document::FlexibleTable.new
data = [["Gregory","Brown"],["James","Healy"],["Jia","Wu"]] Prawn::Document.generate("table.pdf") do # Default table, without headers flexible_table(data) # Default flexible table with headers flexible_table data, :headers => ["First Name", "Last Name"] # Very close to PDF::Writer's default SimpleTable output flexible_table data, :headers => ["First Name", "Last Name"], :font_size => 10, :vertical_padding => 2, :horizontal_padding => 5, :position => :center, :row_colors => :pdf_writer, # Grid border style with explicit column widths. flexible_table data, :border_style => :grid, :column_widths => { 0 => 100, 1 => 150 } end Will raise <tt>Prawn::Errors::EmptyTable</tt> given a nil or empty <tt>data</tt> paramater.
# File lib/prawn/flexible-table.rb, line 41 def flexible_table(data, options={}) if data.nil? || data.empty? raise Prawn::Errors::EmptyTable, "data must be a non-empty, non-nil, two dimensional array of Prawn::Cells or strings" end Prawn::FlexibleTable.new(data,self,options).draw end