Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make tables work in column boxes. Closes #7.

  • Loading branch information...
commit 53e381d5179cd844fabef1d615494bbdfdaa0f34 1 parent 178b566
@bradediger bradediger authored
View
4 lib/prawn/table.rb
@@ -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
2  lib/prawn/table/cell.rb
@@ -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
16 spec/table_spec.rb
@@ -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
+
Please sign in to comment.
Something went wrong with that request. Please try again.