[reportlab-users] Re: error : 'NoneType' object has no attribute 'canv'

Robin Becker reportlab-users@reportlab.com
Mon, 18 Aug 2003 17:26:31 +0100


In article <357E534C-D194-11D7-8E28-0030654ABF76@proboscis.org.uk>,
Proboscis Admin <admin@proboscis.org.uk> writes

Hi Mr Proboscis, sorry about your problem.

First textobjects are not flowables so in general I don't recommend that
you attempt to add them randomly to stories.

Second the Frame class is intended to be used as part of the document
template class' internal book keeping. Unless you are prepared to
inherit from them as a base class and provide a lot of other
infrastructure I fear you may go wrong using them like this.

You should decide if you intend to draw directly onto PDF canvases or to
use the DocTemplate classes which allow for more structured objects.

In the former case texts are done like this

        txt = canvas.beginText(indent, vertical_offset)
        txt.setFont(fontName,fontSize)
        txt.textOut('aaaaaaaa')
        canvas.drawText(txt)

etc

in the latter it would be wise to append flowables to a story list. Then
you can use

        story.append(Paragraph('<font color="red">aaaaaa</font>',
                stylesheet['Code'])

etc.
-- 
Robin Becker