prawn icon indicating copy to clipboard operation
prawn copied to clipboard

Tables in a bounding box

Open DefV opened this issue 15 years ago • 3 comments

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

DefV avatar May 02 '11 13:05 DefV

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? :-)

DefV avatar May 02 '11 13:05 DefV

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.

bradediger avatar May 02 '11 19:05 bradediger

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

bradediger avatar Jun 01 '11 17:06 bradediger