[reportlab-users] Embedding Platypus Story in Canvas

Tim Roberts timr at probo.com
Tue Nov 6 12:55:24 EST 2007


Rich Shepard wrote:

> On Mon, 5 Nov 2007, Tim Roberts wrote:

>

>> Wrong order. It's at the end of "build" that _doSave is checked.

>> You know, you have the full source code on your computer...

>

> Please excuse my apparent denseness. I see in doctemplate.py that def

> build() calls self._endBuild(), and the latter looks for an attributes of

> 'doSave' and 1, but I'm not successful in putting that to use so the

> first

> page is passed to the canvas and processing continues to the following

> pages.

>

> I also see 'self._doSave = 0' in multiBuild(), but not in build(). A

> pointer will be appreciated.


To be honest, I've never tried this, but it looks to me like it should
work. What you want to do is defer the canvas.save() operation until
you have had a chance to do your own damage. When you call build(), it
calls _endBuild, and _endBuild does the canvas.save() if _doSave is
defined to a false value. The getattr function here:

if getattr(self,'_doSave',1): self.canv.save()

says "return the value of the _doSave attribute, or 1 if it is not
defined". By default, _doSave is not defined, so the getattr will
return 1 and the save() will be done. If you define _doSave to
something false (None or 0 or False or '' etc.), it should skip the
save(). In that case, you should be able to fetch the canvas out of the
docTemplate, call showPage(), and continue on with your own drawing.

Maybe that's the issue. Are you fetching the canvas from the doc
template? It creates its own canvas. You can't use your own.

--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the reportlab-users mailing list