Size of a text object
Chris Hobbs <[email protected]>
| Newsgroups | gmane.comp.python.reportlab.user |
|---|---|
| Message-ID | <CAAHPBxw=_ZO2xdi-r31pZf4NTPNJmz8ejV5XqZntbTZCsqnPOg@mail.gmail.com> |
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")
instructions.textLine(..........
[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?
Cheers
Chris