File: cell_dimensions.rb

package info (click to toggle)
ruby-prawn-table 0.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 440 kB
  • ctags: 223
  • sloc: ruby: 3,343; makefile: 5
file content (30 lines) | stat: -rw-r--r-- 1,204 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# encoding: utf-8
#
# To style all the table cells you can use the <code>:cell_style</code> option
# with the table methods. It accepts a hash with the cell style options.
#
# Some straightforward options are <code>width</code>, <code>height</code>,
# and <code>padding</code>. All three accept numeric values to set the property.
#
# <code>padding</code> also accepts a four number array that defines the padding
# in a CSS like syntax setting the top, right, bottom, left sequentially. The
# default is 5pt for all sides.
#
require File.expand_path(File.join(File.dirname(__FILE__),
                                   %w[.. example_helper]))

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::ManualBuilder::Example.generate(filename) do
  data = [ ["Look at how the cells will look when styled", "", ""],
           ["They probably won't look the same", "", ""]
         ]

  {:width => 160, :height => 50, :padding => 12}.each do |property, value|
    text "Cell's #{property}: #{value}"
    table(data, :cell_style => {property => value})
    move_down 20
  end

  text "Padding can also be set with an array: [0, 0, 0, 30]"
  table(data, :cell_style => {:padding => [0, 0, 0, 30]})
end