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  290d444ed0b3413e1c76143b2a2efafec1a3a74d
tree    d3d8badafc6dc3f97e6528929a4bf4dd00a817a2
parent  dc2841af6c223a1564d7a4ed96de5ab27b6c1d71
...
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