[reportlab-users] Re: rotated text (90?) in a table cell
Tim Roberts
timr at probo.com
Wed Oct 18 16:56:35 EDT 2006
Paulino wrote:
>
> well now the script gives some errors:
>
> Traceback (most recent call last):
> File "D:/Python/reportlab/PPI_cabec.py", line 21, in wrap
> return canv._leading, canv.stringWidth(self.text)
> TypeError: stringWidth() takes exactly 4 arguments (2 given)
>
> ......
> I think the missing arguments should be aW, aH
>
>"return canv._leading, canv.stringWidth(self.text, aW, aH)"
>
>
No. A quick perusal of either the manual or the source code would have
shown you that stringWidth expects the text, the fontname, and the fontsize.
return canv._leading, canv.stringWidth( self.text, canv._fontname,
canv._fontsize )
Given the fact that virtually all stringWidth calls use the current
canvas font and size, I've never understood why the stringWidth method
didn't default to those:
def stringWidth(self, text, fontName=None, fontSize=None):
"gets width of a string in the given font and size"
if not fontName:
fontName = self._fontname
if not fontSize:
fontSize = self._fontsize
return pdfmetrics.stringWidth(text, fontName, fontSize)
or maybe
def stringWidth(self, text, fontName=None, fontSize=None):
"gets width of a string in the given font and size"
return pdfmetrics.stringWidth(text,
fontName or self._fontname,
fontSize or self._fontsize)
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the reportlab-users
mailing list