[reportlab-users] a replicated canvas?
robin at reportlab.com
Tue Sep 18 07:19:22 EDT 2007
Jon Bradley wrote:
> I posted a while back and now am in the process of actually building
> some content from a front-end application (written in Adobe Flex).
> I've only got two assets that I need to place into the PDF file - but
> the problem is that I need to place them multiple times.
> One specific "form" or "canvas" of the PDF will consist of a background
> image and a text field on top of that (at a specific size, position and
> color). The text field is populated from a database.
> I'd like to know if there is a method whereby I can create a canvas on
> the PDF, and replicate that 8 times per page (2 columns, 4 rows).
> I've looked through the docs and I don't see anything that is going to
> help me do this quicker than adding each one specifically. Ideally I'd
> loop over the pages, then the rows/columns and place the elements.
> for i in pages
> for j in columns
> for k in rows
> place image
> place text
> set text properties
> Is this how you would suggest I do this? I don't understand the PDF
> format fully, and the image I am adding is just being replicated
> multiple times and I'm concerned the file size will be humongous. Only
> that single text field will change from canvas to canvas.
> Any tips are most appreciated.
> - jon
You can create a form and place that multiple times on the same pdf canvas.
So if you have a pdfgen.canvas.Canvas instance c
you can do
c.draw...... other ops etc etc
to define the form and later
you can repeat the doForm in different userspace transformations to get the form
in different places on the page.
More information about the reportlab-users