[reportlab-users] a replicated canvas?

Andy Robinson andy at reportlab.com
Tue Sep 18 11:24:06 EDT 2007

On 18/09/2007, Jon Bradley <shiftedpixels at gmail.com> wrote:

> > you can repeat the doForm in different userspace transformations to

> > get the form in different places on the page.


> Ah... that sounds great. But then what do I do about modifying that

> text field within "c" during my loops for placing it on the page. Can

> I modify the form after the fact - ie, c.myform.value = something,

> then process the doForm method at the current x,y position?

No, that would defeat the whole point. A PDF "Form XObject" is
actually a chunk of graphics stored in a separate part of the PDF
file, and called 'by reference' on each page, so it must be identical
each time.

I suggest you just make a function like this...

def drawMyStuff(x, y, my_variable_text):
# draw my image using canvas.drawImage, shifted by x and y
# draw my text, shifted by x and y

...then call it in two nested loops as you move across and down the page.
If you use drawImage, it will cache the bitmap files intelligently as
PDF also provides for this.

- Andy

More information about the reportlab-users mailing list