Skip to content

Commit

Permalink
Merge pull request #723 from prawnpdf/issue_721
Browse files Browse the repository at this point in the history
fixes #721 + test case
  • Loading branch information
practicingruby committed May 28, 2014
2 parents 8b4fbd8 + b44ac91 commit ed3d144
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/prawn/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ def add_header(page_of_cells, x_offset, y, row, row_of_header=nil)
rows_to_operate_on = @header_row.rows(row_of_header) if row_of_header
rows_to_operate_on.each do |cell|
cell.row = row
cell.dummy_cells.each {|c| c.row = row }
cell.dummy_cells.each {|c| c.row = row + c.row }
page_of_cells << [cell, [cell.x + x_offset, y]]
end
rows_to_operate_on.height
Expand Down
23 changes: 23 additions & 0 deletions spec/table_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# encoding: utf-8

# run rspec -t issue:XYZ to run tests for a specific github issue
# or rspec -t unresolved to run tests for all unresolved issues

require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
require 'set'

Expand Down Expand Up @@ -45,6 +48,26 @@
end
end

describe "headers should allow for rowspan" do
it "should remember rowspans accross multiple pages", :issue => 721 do
pdf = Prawn::Document.new({:page_size => "A4", :page_layout => :portrait})
rows = [ [{:content=>"The\nNumber", :rowspan=>2}, {:content=>"Prefixed", :colspan=>2} ],
["A's", "B's"] ]

(1..50).each do |n|
rows.push( ["#{n}", "A#{n}", "B#{n}"] )
end

pdf.table( rows, :header=>2 ) do
row(0..1).style :background_color=>"FFFFCC"
end

#ensure that the header on page 1 is identical to the header on page 0
output = PDF::Inspector::Page.analyze(pdf.render)
output.pages[0][:strings][0..4].should == output.pages[1][:strings][0..4]
end
end

describe "Text may be longer than the available space in a row on a single page" do
it "should not glitch the layout if there is too much text to fit onto a single row on a single page", :unresolved, :issue => 562 do
pdf = Prawn::Document.new({:page_size => "A4", :page_layout => :portrait})
Expand Down

0 comments on commit ed3d144

Please sign in to comment.