[reportlab-users] Size of a text object

Chris Hobbs cwlh at farmhall.ca
Tue Mar 25 22:22:38 EDT 2014

I am fitting various pieces of text onto a page and need to know the size
of a text object (so that I know whether it will fit onto a page or not).

It appears from the code that I can use

(x,y) = obj.getStartOfLine()

to find the y position of the last (current) line, but that's no use in
finding the maximum value of x.

Adding a obj.getX() after each obj.textLine() doesn't help because the
cursor is back on the left margin by then.

So, in summary, I would like to do

canvas.setFont("Helvetica", 8)
instructions = canvas.beginText(mm*20, mm*yPosn)
instructions.textLine("The boy stood on the burning deck")
instructions.textLine("whence all but he had fled")

[find the size of this text object]

canvas.drawText(instructions) # if small enough to fit on page

Is there are way I can do this in reportlab?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20140325/c8ccf318/attachment.html>

More information about the reportlab-users mailing list