Rounded Stroke For Bounding Box Spanning Multiple Pages

460 views
Skip to first unread message

James

unread,
May 27, 2012, 9:41:56 PM5/27/12
to Prawn
Basically, I want to have a rounded corner table per design
requirements for a project that I am working on.

Since, I cant figure out how to make table cells have a radius, I am
just putting a rounded rectangle on top of my table. It was working
fine until I realized that occasionally my table, which is placed
inside of a bounding box, will span multiple pages on occasion. In
this case, I have not figure out how to force my rounded rectangle to
draw around both parts of the split table inside the bounding box?

Any ideas here or do I need to write a few custom methods?

Thanks!

Brad Ediger

unread,
May 28, 2012, 3:45:14 PM5/28/12
to prawn...@googlegroups.com
Hmm, that's a tricky one. The trouble is that Prawn doesn't have a
concept of "the part of this table that fits on page X" -- it just
draws cells, which are responsible for drawing their own borders. So
in order to draw a rounded rectangle around the cells on a particular
page, you might have to either override the code that divvies up cells
across pages or hook start_new_page during table drawing.

-be

James Hayton

unread,
May 28, 2012, 4:22:54 PM5/28/12
to prawn...@googlegroups.com
Thanks for the reply. That was pretty much what I thought, but I just wanted to make sure first. I didn't know if there was a way to get the height of the bounding box on each page that I am missing. The last page works fine, but the first pages don't since I don't know the height the table prawn will take on page 1 until prawn draws it.

Can I go back to the first pages somehow after prawn moves to page 2/3, etc...?

I can get close using pdf.y for the height of the full page tables but sometimes the table doesn't take up full page since prawn correctly doesn't print partial rows. So I more or less am left with creating a custom draw method.

I was just going to create draw_rounded(radius) or something and implement the functionality I need there. Not very pretty, but I would have access to everything I need in the draw method from reading the source.

Any other advice any prawn experts have would be appreciated. Thanks!

James
Reply all
Reply to author
Forward
0 new messages