[reportlab-users] another question on headers and footers
Tim Roberts
timr at probo.com
Mon Aug 8 13:20:33 EDT 2005
On Mon, 8 Aug 2005 11:29:52 +0200 (CEST), Nicholas Wieland
<nicholas_wieland at yahoo.it> wrote:
>How can I pass arguments to onPage and onPageEnd callables ?
>For example, I need to display a date in my header, so actually I'm using a global :(
>
>Suggestions ?
>
>
If it's just "today's date" you need, just import datetime or mxDateTime
or whatever, and call the functions in onPage.
If you have a specific string you need to pass, remember that a canvas
is just a Python object. You can add your own attributes.
class myReport:
def __init__(self):
self.canvas = canvas.Canvas( ... )
self.canvas.myExtraData = { 'today': "Today is the Day" }
...
def onPageEnd(canvas, doc):
...
canvas.drawString( x, y, canvas.myExtraData['today'] )
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the reportlab-users
mailing list