[reportlab-users] Embedding Platypus Story in Canvas

Uwe C. Schroeder uwe at oss4u.com
Tue Nov 6 16:38:22 EST 2007



On Tuesday 06 November 2007, Tim Roberts wrote:

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



you have to add _doSave to the initargs of BaseDocTemplates in platypus.py if
it isn't there (in my build it isn't). You can't overwrite it if it isn't
defined there.


UC

--
Open Source Solutions 4U, LLC 1618 Kelly St
Phone: +1 707 568 3056 Santa Rosa, CA 95401
Cell: +1 650 302 2405 United States
Fax: +1 707 568 6416


More information about the reportlab-users mailing list