public
Description: Fast, Nimble PDF Writer for Ruby
Homepage: http://prawn.majesticseacreature.com
Clone URL: git://github.com/sandal/prawn.git
Pagination and height specs [#32]
sandal (author)
Tue Jun 24 22:24:07 -0700 2008
commit  bdbe00ed23c4287d0a18907c7f8d179224b0171f
tree    a2945a97709cd34ff00d1559e0b37e54072b55cb
parent  d2612fe2755995c3bc923bff4bf781901e2b1c32
...
45
46
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
...
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
0
@@ -45,4 +45,32 @@ describe "A table's width" do
0
 
0
   end
0
 
0
+  it "should paginate large tables" do
0
+    # 30 rows fit on the table with default setting, 31 exceed.
0
+    data = [["foo"]] * 31
0
+    pdf = Prawn::Document.new
0
+
0
+    pdf.table data
0
+    pdf.page_count.should == 2
0
+
0
+    pdf.table data
0
+    pdf.page_count.should == 3
0
+  end
0
+
0
+  it "should have a height of n rows + vertical padding" do
0
+    data = [["foo"],["bar"],["baaaz"]]
0
+    pdf = Prawn::Document.new
0
+    num_rows = data.length
0
+    vpad     = 4
0
+    
0
+    origin = pdf.y
0
+    pdf.table data, :vertical_padding => vpad
0
+
0
+    table_height = origin - pdf.y
0
+
0
+    font_height = pdf.font_metrics.font_height(12)
0
+
0
+    table_height.should be_close(num_rows*font_height + 2*vpad*num_rows + vpad, 0.001)
0
+  end
0
+
0
 end

Comments