[reportlab-users] how do you include an image within a frame with other flowables?
Andy Robinson
reportlab-users@reportlab.com
Wed, 13 Nov 2002 08:03:48 -0000
> I tried doing:
>
> img = Image(0, 0, 1.5*inch, 0.5*inch, "test.gif")
> imageFrame.addFromList(img,c)
If you just want to draw an image at a known location
on the canvas, forget frames and draw it direct.
Flowables in general must be told the available space
first, but this will not a make a difference to an image.
# may not be needed for images, give it a try without
img.wrap(width, height)
img.drawOn(c, x, y)
The whole idea of frames is that they "consume from a list"
of content, so you can flow a sequence of paragraphs,
images and tables into them. They 'eat things' off the
front of the list so you can see what is list. So,
pout that image in a list:
Try:
imageFrame.addFromList([img],c)
Or to make it clearer,
content = [img]
imageFrame.addFromList(content,c)
There are 3 levels of sophistication with Playtpus and
the trick is to use no more than you need:
1. Flowables are objects which can be drawn on the canvas
2. Frames can flow a sequence of flowables downwards
3. DocTemplates will automatically move from page to
page and frame to frame.
Hope this helps,
Andy