[reportlab-users] Scaling text to fit remaining space

Marius Gedminas reportlab-users@reportlab.com
Tue, 27 Aug 2002 16:21:36 +0200


On Tue, Aug 27, 2002 at 10:12:20AM -0400, JamesClementsIII@netscape.net wrote:
> How do I measure the length of a string before deciding to place it on
> a page.  When I'm filling in tables of a fixed size, I would like to
> have the option of shrinking a string 3-5% to make it fit.

If you know the font name and size, you can use

  pdfmetrics.stringWidth(text, fontname, fontsize)

Marius Gedminas
-- 
Mosher's Law of Software Engineering:
        Don't worry if it doesn't work right.
        If everything did, you'd be out of a job.