[reportlab-users] drawing on canvas while using platypus

Robin Becker robin at reportlab.com
Thu Aug 5 12:55:51 EDT 2010

On 05/08/2010 14:51, Christian K. wrote:

> Am 05.08.10 15:23, schrieb Christian K.:

>> Am 05.08.10 14:04, schrieb Rafael Lopes:

>>> 2010/8/5 Christian K.<ckkart at hoc.net>:

>>>> what are the limits for the width and height instance variables of a

>>>> Flowable?


>>> The limits are the canvas' limits. You just have to be sure that you

>>> use the right coordinates.


> I made some progress. Using a BaseDocTemplate with my own Frame, I got

> some good results. Interstingly the origin of the coordinate system of

> my custom flowable is in the top left corner, so that the visible

> y-coordinates are negative. Is that intended?


> Christian


when a flowable in the story is added to a frame the frame works out where the
flowable should be added and then calls the wrap method to ask the flowable how
much space it needs. If the flowable returns width and height that won't fit the
frame aborts the request and the platypus frame work then tries to get the
flowable to split itself. If the flowable declines by returning just one item in
a list then the framework tries to move to the top of a frame and retries.

If a flowable can fit in the current space as determined by a call to

w,h = f.wrap(aW,aH) #available width and height --> required width & height

then the frame will draw the flowable by calling its drawOn method like

flowable.drawOn(canv, self._x + self._leftExtraIndent, y, _sW=aW-w)

here self._x is the drawing area edge, y is the bottom of the drawable region
(as determined by the frame).

In reportlab the lower left hand corner is the origin so y increases up the
page. Normally drawOn will be called with x,y as the lower left corner of the
region that the flowable will draw in. However, you're not required to use any
translations in an overridden drawOn method, but the default method certainly does.
Robin Becker

More information about the reportlab-users mailing list