| Class | Prawn::Document |
| In: |
lib/prawn/flexible-table.rb
|
| Parent: | Object |
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.