[reportlab-users] string width

Robin Becker reportlab-users@reportlab.com
Tue, 04 May 2004 10:46:33 +0100


Alexander Blüm wrote:
> hello,
> 
> is there any way of calculating the resulting width of the written or
> to-be-written string using any other font than curier?
> 
> arial, for example has different widths for these
> letters: l,i,J,f,t,W,K  and so on - you get the idea.
> 
> TIA
> 
There is a string width function.

from reportlab.pdfbase.pdfmetrics import stringWidth
print stringWidth('Hello World','Times-Roman',14)


-- 
Robin Becker