[reportlab-users] Querying left over space
Mike Driscoll
mdriscoll at co.marshall.ia.us
Mon Sep 14 13:47:56 EDT 2009
Robin Becker wrote:
> Mike Driscoll wrote:
>> Hi,
>>
>> Is there a way to query how much horizontal and vertical space is
>> left on a page? And is there a way to know how much "space" a line of
>> text in 10 point will take up? I am working with nested tables and it
>> keeps splitting one of the nested over two pages whereas I need it to
>> keep the nested table in one piece. I hope that makes sense.
>>
>> I am coding on a Windows XP machine with Python 2.5 and ReportLab 2.3.
>>
>> Thanks,
>>
>> Mike
> ......
> I assume that you're using platypus to do the layout; the document's
> active template has an active frame that controls the layout. The
> coding that's used to determine whether something can be added is in
> the _add method of the Frame class. It looks something like this
I'm using the SimpleDocTemplate from platypus, if that's what you mean.
Then I use the Table object to create some tables and nest them as
needed. The code works fine except that it splits in the middle of
tables sometimes. I need some kind of grouping function to keep the
tables whole...
>
> y = self._y
> p = self._y1p
> s = 0
> aW = self._getAvailableWidth()
> if not self._atTop:
> s =flowable.getSpaceBefore()
> if self._oASpace:
> s = max(s-self._prevASpace,0)
> h = y - p - s
> if h>0:
> w, h = flowable.wrap(aW, h)
> else:
> return 0
> h += s
> y -= h
> if y < p-_FUZZ:
> if not rl_config.allowTableBoundsErrors and ((h>self._aH or
> w>aW) and not trySplit):
> from reportlab.platypus.doctemplate import LayoutError
> raise LayoutError("Flowable %s (%sx%s points) too large
> for frame (%sx%s points)." % (
> flowable.__class__, w,h, aW,self._aH))
> return 0
> else:
> #DRAW THE FLOWABLE AT self._x, y
>
> if you ignore the space before stuff then effectively the vertical
> space remaining is
> activeFrame._y - activeFrame._y1p
>
> hope this helps.
Hmmm...not sure how to use this, but will try to figure it out. Do I
create a frame object to grab that information from?
- Mike
More information about the reportlab-users
mailing list