[reportlab-users] vertical alignment for xpreformatted

Tim Roberts timr at probo.com
Thu Nov 29 17:21:52 EST 2007


Michael Hearne wrote:

> Is there some sort of vertical alignment attribute or method for

> frames or xpreformatted instances? I'm trying to get some text to use

> up all of the space in a frame and it keeps getting squished towards

> the middle, as the code snippet below hopefully demonstrates. I did

> look at the documentation and searched the for examples, but they all

> seemed to relate to troubles with tables.


Why are you using flowables at all if you need such complete control
over the placement? You may want to consider forgetting about Platypus
and placing the text on your own.


> stylesheet = getSampleStyleSheet()

> style = stylesheet['Normal']

> text = '<para alignment="right"> <font size="32">\n'

> text = text + "<b>Hello world!\nI'm right here</b>\n\n"

> text = text + '</font></para>'

> print text


The space on top comes from the newline at the end of your first
string. That puts a blank line at the top. The squishiness happens
because you're changing the font size but not the leading. Try this:

text = '<para alignment="right" font=32pt leading=34pt>'
text += "<b>Hello world!\nI'm right here</b>"
text += "</para>"

--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the reportlab-users mailing list