[reportlab-users] How to properly get alignments of flowables right...

Robin Becker robin at reportlab.com
Thu Oct 1 05:35:36 EDT 2009

Brower Jason wrote:

> I felt I was doing something similar now.

> ---

> salesman_comments = "This is something called lorem ipsom text.<br/> It

> is used as a filler text. Lorem ipsum dolor sit amet, consectetur

> adipisicing..."

> style = getSampleStyleSheet()

> P=Paragraph(salesman_comments,style["Normal"])

> P.wrap(140, 800)

> P.drawOn(pdf,6.1*cm,4.5*cm)

> pdf.showPage()

> pdf.save()

> ---

> But it looks like I have to make adjustments from the bottom left corner

> of the object. It doesn't seem logical that way. Is there something I

> am missing about doing zero point of the object at the top left of

> itself?

> Otherwise as my dynamic text gets longer it pulls the top higher and

> higher.

> Regards,

> Jason


the above looks right, but bottum up is our standard way of doing things (like
in maths the origin is lower left). We measure from the ground up and not from
an infinite distance above etc etc etc.

Frame objects position flowables starting at the top of their area and gradually
reduce the position at which the next flowable should be added. To position your
paragraph's top left at a specified point x,y you need to do

w,h = P.wrap(140,800)

of course y here is from the bottom of the page, but if pagesize = pw, ph then
it's trivial to do stuff like

P.drawOn(pdf,1.5*cm,ph-1.5*cm-h) ie position the top left of the paragraph 1.5cm
from the left and top of the page.

Robin Becker

More information about the reportlab-users mailing list