Permalink
Browse files

Make tables work in column boxes. Closes #7.

  • Loading branch information...
1 parent 178b566 commit 53e381d5179cd844fabef1d615494bbdfdaa0f34 @bradediger bradediger committed Jan 11, 2010
Showing with 19 additions and 3 deletions.
  1. +2 −2 lib/prawn/table.rb
  2. +1 −1 lib/prawn/table/cell.rb
  3. +16 −0 spec/table_spec.rb
View
@@ -331,11 +331,11 @@ def generate_table
bbox = @parent_bounds.stretchy? ? @document.margin_box : @parent_bounds
if c.height > y_pos - bbox.absolute_bottom
if C(:headers) && page_contents.length == 1
- @document.start_new_page
+ @parent_bounds.move_past_bottom
y_pos = @document.y
else
draw_page(page_contents)
- @document.start_new_page
+ @parent_bounds.move_past_bottom
if C(:headers) && page_contents.any?
page_contents = [page_contents[0]]
y_pos = @document.y - page_contents[0].height
View
@@ -247,7 +247,7 @@ def <<(cell)
def draw
y = @document.y
- x = @document.bounds.absolute_left
+ x = @document.bounds.left_side
@cells.each do |e|
e.point = [x - @document.bounds.absolute_left,
View
@@ -319,3 +319,19 @@
end
end
+
+describe "A table, in a column box" do
+
+ it "should flow to the next column rather than always the next page" do
+ pdf = Prawn::Document.new do
+ column_box [0, cursor], :width => bounds.width, :columns => 2 do
+ # 35 rows fit on two columns but not one
+ table [["data"]] * 35
+ end
+ end
+
+ pdf.page_count.should == 1
+ end
+
+end
+

0 comments on commit 53e381d

Please sign in to comment.