[reportlab-users] How to use forms in combination with Platypus

Robin Becker robin at reportlab.com
Fri Feb 17 10:30:52 EST 2006

Remi Cool wrote:
> Hello,
> I want to use a form to print a watermark text on every page, normally
> not a problem, but I'm using platypus for my document generation. The
> problem is that I can't define the form before docTemplate.build is
> called. You need the canvas to define the form and the canvas is not
> present beforehand (beforeDocument).
> How can I solve this problem without hacking the docTemplate class?
> Using the form should not be a problem ... I think ... am I correct that
> I can use the onPage method of the PageTemplate to accomplish this task?
> def watermark(canv, doc):
>     canv.doForm('myForm')
> myPageTemplate.onPage = watermark

yes, but you can also use the onPage function to check if the form has been 
added yet. First time you know you need to define the form eg

def watermark(canv, doc):
     if not canv.hasForm('myForm'):


Robin Becker

More information about the reportlab-users mailing list