public
Description: Fast, Nimble PDF Writer for Ruby
Homepage: http://prawn.majesticseacreature.com
Clone URL: git://github.com/sandal/prawn.git
prawn / bugs / table_row_background_color_issue.rb
100644 50 lines (43 sloc) 2.061 kb
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# As of 96f660660345c7c22923ba51d0124022a3a189ab, table is currently not taking
# in account border widths when filling in rows with background coloring. This
# means the larger the border, the larger the visible gap between rows.
 
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
require "prawn"
 
Prawn::Document.generate("table_with_background_color_problems.pdf") do
  font "#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf"
  table [["ὕαλον ϕαγεῖν", "baaar", "1" ],
         ["This is","a sample", "2" ],
         ["Table", "dont\ncha\nknow?", "3" ],
         [ "It", "Rules", "4" ],
         [ "It", "Rules", "4" ],
         [ "It", "Rules", "4" ],
         [ "It", "Rules", "4" ],
         [ "It", "Rules", "4" ],
         [ "It", "Rules", "4" ],
         [ "It", "Rules", "4" ],
         [ "It", "Rules", "4" ],
         [ "It", "Rules", "4" ],
         [ "It", "Rules\nwith an iron fist", "x" ],
         [ "It", "Rules", "4" ],
         [ "It", "Rules", "4" ],
         [ "It", "Rules", "4" ],
         [ "It", "Rules", "4" ],
         [ "It", "Rules", "4" ],
         [ "It", "Rules", "4" ],
         [ "It", "Rules", "4" ],
         [ "It", "Rules", "4" ],
         [ "It", "Rules", "4" ]],
 
    :font_size => 24,
    :horizontal_padding => 10,
    :vertical_padding => 3,
    :border => 2,
    :position => :center,
    :headers => ["Column A","Column B","#"],
    :row_colors => ["eeeeee"]
 
  pad(20) do
    text "This should appear in the original font size"
  end
 
  table [[ "Wide", "columns", "streeetch"],
         ["are","mighty fine", "streeeeeeeech"]],
    :widths => { 0 => 200, 1 => 250 }, :position => 5
 
end