How to refer to label height and width from inside the loop?
mathuin opened this issue · 4 comments
My labels include a background image and some tables. I need to know the height and width of the label to set things up correctly. When using grid, I was able to access grid.column_width and grid.row_height, but I can't see how to do that from within the label loop. Help?
Jack.
That seems a little more complicated then what this library was meant to do. You'll need to do one of two things:
- Patch prawn-labels so the current grid position (https://github.com/jordanbyron/prawn-labels/blob/master/lib/prawn/labels.rb#L79) is yielded to the block
- Use prawn-labels as a guide to create your own custom pdf which outputs the correct size and grid.
Let me know which way you decide to go. Thanks!
Jordan
On Oct 20, 2011, at 3:32 PM, Jack Twilley wrote:
My labels include a background image and some tables. I need to know the height and width of the label to set things up correctly. When using grid, I was able to access grid.column_width and grid.row_height, but I can't see how to do that from within the label loop. Help?
Jack.
Reply to this email directly or view it on GitHub:
#7
I will first try to yield the grid variable itself to the block and see if that gives me enough, just in case someone else needs something else from the grid.
I will create another issue about the fact that I can't make an image or a table, even when I explicitly refer to Prawn::Images.image() etc. I am hopeful as grid gives me the power to shape the contents exactly how I like, but labels gives me the ability to distribute that content without regard to how many labels are on a page or any other trivia. Thank you for writing such good stuff!
Jack.
I will first try to yield the grid variable itself to the block and see if that gives me enough, just in case someone else needs something else from the grid.
Ok. Just make sure that isn't an API breaking change. All the example PDFs should still run without modification after your change.
It turns out the grid variable is already yielded to the block as pdf.grid -- I am using pdf.grid.column_width and pdf.grid.row_height successfully. No need to add code!
Jack.