[reportlab-users] ValueError: redefining named object

Robin Becker robin at reportlab.com
Mon Feb 18 07:23:34 EST 2008


jo wrote:

>

> I see the line that cause this error is this one:

> self.ss['tx'].setFont('OCR', 10)

>

> seems reportlab can performs setFont() only the first time but this happen

> only when the font is defined by user.

> I wonder if there's a workaround to avoid this error.

>

> def display(self):

> self.ss['tx'] = self.ss['cnvs'].beginText()

> self.ss['eli'] = self.ss['cnvs'].beginPath()

>

> self.ss['tx'].setHorizScale(100)

> self.ss['tx'].setTextOrigin(0,0)

> self.ss['tx'].moveCursor(

> (self.ss['borderx'] + (self.ss['pxriga'] * 31)),

> (self.ss['bordery'] + (self.ss['pxriga'] * 1))

> )

> self.ss['tx'].textOut("printing...")

> self.ss['cnvs'].drawText(self.ss['tx'])

> self.ss['cnvs'].showPage()

> self.ss['cnvs'].save()

>

> jo

.......
try:
self.ss['tx'].setFont('OCR', 10)
except:
pass

or better

def startup(self):
# do things required only once
self.ss['tx'].setFont('OCR', 10)

--
Robin Becker


More information about the reportlab-users mailing list