[reportlab-users] Embedding Platypus Story in Canvas

Rich Shepard rshepard at appl-ecosys.com
Tue Nov 6 18:17:18 EST 2007


On Tue, 6 Nov 2007, Tim Roberts wrote:


> You have two choices.

...

> 2. You can derive your own class from SimpleDocTemplate, and override

> _startBuild to use the canvas you pass in.


I'm really in a hole. Did this but still no joy. Here's the class:

class MyTemplate(SimpleDocTemplate):
_invalidInitArgs = ('pageTemplates',)

myCanvas = canvas.Canvas('input_variables.pdf', pagesize=LETTER)

def _startBuild(self, filename='input_variables.pdf', canvasmaker=myCanvas):
self._calc()
self.canv = canvasmaker(filename or self.filename,
pagesize=self.pagesize,
invariant=self.invariant,
pageCompression=self.pageCompression)
if self._onPage:
self.canv.setPageCallBack(self._onPage)
self.handle_documentBegin()

And in class ProjectReports() I assign

pg = MyTemplate.myCanvas

so all additional references to pg become self.pg. No python errors, but
still only a one-page report.

My inexperience with Python is certainly on public display here.

Rich

--
Richard B. Shepard, Ph.D. | Integrity Credibility
Applied Ecosystem Services, Inc. | Innovation
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863


More information about the reportlab-users mailing list