Sha256: b821d0d1683c11e768e9b7a7bbb5a3324633b690441a7504037225806259e11a

Contents?: true

Size: 1.65 KB

Versions: 6

Compression:

Stored size: 1.65 KB

Contents

# encoding: utf-8
#
# Generates a couple simple tables, including some UTF-8 text cells.
# Although this does not show all of the options available to table, the most
# common are used here.  See fancy_table.rb for a more comprehensive example.
#
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', 'lib'))

require "rubygems"
require "prawn"
require "prawn/layout"

Prawn::Document.generate("table_widths.pdf") do 

  data = [
    %w(one two three four),
    %w(five six seven eight),
    %w(nine ten eleven twelve),
    %w(thirteen fourteen fifteen sixteen),
    %w(seventeen eighteen nineteen twenty)
  ]
  headers = ["Column A","Column B","Column C", "Column D"]

  text "A table with a specified width of the document width (within margins)"
  move_down 10

  table data,    
    :position   => :center,
    :headers    => headers,
    :width      => margin_box.width


  move_down 20
  text "A table with a specified width of the document width (within margins) and two fixed width columns"
  move_down 10

  table data,    
    :position      => :center,
    :headers       => headers,
    :width         => margin_box.width,
    :column_widths => {0 => 70, 1 => 70}


  move_down 20
  text "A table with a specified width of 300"
  move_down 10

  table data,    
    :position   => :center,
    :headers    => headers,
    :width      => 300


  move_down 20
  text "A table with too much data is automatically limited to the document width"
  move_down 10

  data << ['some text', 'A long piece of text that will make this cell too wide for the page', 'some more text', 'And more text']

  table data,    
    :position   => :center,
    :headers    => headers

end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
sskirby-prawn-layout-0.1.1 examples/table/table_widths.rb
prawn-flexible-table-0.1.2 examples/table_widths.rb
prawn-flexible-table-0.1.1 examples/table_widths.rb
prawn-flexible-table-0.1 examples/table_widths.rb
prawn-layout-0.2.0.1 examples/table/table_widths.rb
prawn-layout-0.1.0 examples/table/table_widths.rb