[reportlab-users] Nested Flowables?

Robin Becker robin at reportlab.com
Thu Jan 7 11:16:54 EST 2010


On 07/01/2010 15:50, Kevin D Smith wrote:

> I did find out part of my problem. My outer flowable was being drawn, then the next one was drawn above it which happened to be above the page. So I'm trying to figure out how to get the placement of the nested flowables correct. I can't quite follow what's going on with them right now because they go off the page. I've tried doing translates after each nested flowable to put the cursor back into the correct place, but that doesn't seem to be working reliably for me. Is there a way to get the absolute position of the cursor on the canvas? I think if I could get that value it might help me figure out what's going on.

>

>

> On Jan 6, 2010, at 10:21 AM, Kevin D Smith wrote:

>

>> I'm working on a renderer that needs to handle nested flowables. I essentially want to be able to render something equivalent to the following:

>>

>> <div>

>> <div>

>> <span>text</span>

>> <div>

>> <span>more text</span>

>> </div>

>> </div>

>> </div>

>>

>> where each div can have its own borders and padding and can break across a page. I've got the page breaking worked out, but drawing on the page is giving me some trouble. I'm not exactly sure where I am on the page when I start drawing. I did some random translations just to get something on the page and I found out that I needed to translate by -380 vertically to get my content in the right place. I also had trouble drawing each piece within a nested div. I'm trying to figure out where I left off on the previously drawn div, but it isn't working as well as I had hoped. If someone can enlighten me on what might be going wrong, I'd appreciate it.

>>

>> Kevin D Smith

>> Kevin.Smith at sixquickrun.com

.........
well without knowing what you mean by renderer it's hard to answer your
questions. You can draw flowables directly to a canvas or use the
doctemplate/frames framework. Which approach or style are you using?

One thing that confuses people is that although flowables are supposed to flow
down their frames they are actually drawn bottom up like all objects that get
drawn to the canvas (in which 0,0 is at the bottom left corner). Obviously
frames have to take account of this so they find the width/height first and then
adjust the drawing position based on that and the internal height from the top
of the frame represented by how much has been place therein already.
--
Robin Becker


More information about the reportlab-users mailing list