[reportlab-users] Size of a text object
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
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...
More information about the reportlab-users