Tables in a bounding box
Ever since commit 966e126ad15b809febf6a5d1d5d12f3b263e2661 tables in bounding-boxes look garbled. I can't make sense on why this happens, so I'm opening a ticket.
This is what I get when I generate a simple table in a bounding box: https://skitch.com/defv/r7dc2/prawntest.pdf-1-page This is the code that generated that PDF: https://gist.github.com/ab55fb2db75418953fe0
The problem seems to be in Prawn::Table::Cell#draw_bounded_content, which changes @pdf.y. Before, the loop calculated that in and the y to start drawing was recalculated before drawing each cell, so the changed y coordinate was compensated.
I fixed it like this:
def draw_bounded_content(pt)
original_y = @pdf.y
@pdf.bounding_box([pt[0] + padding_left, pt[1] - padding_top],
:width => content_width + FPTolerance,
:height => content_height + FPTolerance) do
draw_content
end
@pdf.y = original_y
end
which works, but isn't a clean solution. Any takers? :-)
Thanks DefV for reporting the issue. As soon as I can get some time to write a good spec and fix the issue, this will be resolved.
Hi DefV, Sorry it took so long to get a fix in place; things have been quite busy. This should now be resolved on Prawn master. Thanks for your contribution to Prawn!
Brad