prawnpdf/prawn-table — pull request #16 by hbrandl (2014-08-26 14:35:36+00:00)
Title: optionally allow prawn-table to split (text) rows if they don't fit on a page

This is a first attempt at fully fixing issue #3.
Although I did test it with quite a few variations, there may still be one or a couple of edge cases that I didn't think of.

It can only split "normal" (unrotated etc.) text. If you pass it anything else it will stick to the current / old behavior. To enable this feature you have to pass the option ```` split_cells_in_final_row: true ```` to the table command. e.g.

```` ruby
@pdf.table(@data, split_cells_in_final_row: true)
````

@johnnyshields @Bharat311 and everyone else: Please try this branch with your data and try to break it. :-) Do report any problems here in this pull request.

Once you confirm that the code is working, I'll go ahead and refactor it A LOT to make it more readable, cleaner and beautiful. Further I still have to improve / add more test cases and of course documentation before I'll merge this. As a final step I'll squash all commits into a single one.

Some sample code to test the new behaviour
```` ruby
require 'prawn'
require 'prawn/table'

@pdf = Prawn::Document.new
@data = []
# just enough lines, so that the next one will break if it uses more than one line
@data.push [{content: 'header1', rowspan: 2, colspan: 2}, {content: 'header1', colspan: 2}, {content: 'header1', colspan: 2}]
@data.push [{content: 'header2', colspan: 2}, {content: 'header1', colspan: 2}]
25.times do |i|
@data.push ["row #{i}/1", "row#{i}/2", "row#{i}/3", "row#{i}/4", "row#{i}/5", "row#{i}/6"]
end
@data.push ["row 25/1", {content: "row25/2"}, "row25/3", "row25/4", "row25/5", "row25/6"]
@data.push [{content: "this is a very long line that needs a lot of space", rowspan: 4}, "row26/2", "row26/3", "row26/4", "row26/5", "row26/6"]
#@data.push [{content: "this line is too long to fit in two columns and only one row", colspan: 2}]*3
@data.push [ {content: 'foobar'}, {content: "this line is too long to fit in two columns and only one row", colspan: 2}, {content: 'final cell colspan 2', colspan: 2}]
@data.push [ "row -2 /2", "row -2 /3", "row -2 /4", "row -2 /5", "row -2 /6"]
@data.push [ "row -1 /2", "row -1 /3", "row -1 /4", "row -1 /5", "row -1 /6"]
@data.push [ "row last/1", "row last/2", "row last/3", "row last/4", "row last/5", "row last/6"]
@table = @pdf.table(@data, column_widths: 80, split_cells_in_final_row: true, header: 3)
@pdf.render_file('test.pdf')
````