Skip to content

Commit

Permalink
Make tables work in column boxes. Closes #7.
Browse files Browse the repository at this point in the history
  • Loading branch information
bradediger committed Jan 11, 2010
1 parent 178b566 commit 53e381d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/prawn/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/prawn/table/cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 16 additions & 0 deletions spec/table_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.