[reportlab-users] ValueError: redefining named object

jo jose.soares at sferacarta.com
Mon Feb 18 08:55:05 EST 2008


Robin Becker ha scritto:

> 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)

>

Thank you, Robin for your help.

Your tip should be a solution only if I use the same font and the same
size in whole document,
infortunately I have to use more than one font and more than one size in
the entire document,
because reportlab uses the last font setting, I am not able to change
font and size.

if I use 'OCR', size 10 to print the 1st line and I need to change the
size from 10 to 8 to print the 2nd line,
I can't do that.


jo










More information about the reportlab-users mailing list