[Image-SIG] Images in Zope/ReportLab

Heiner de Wendt H.dewendt@systec.de
Wed, 9 May 2001 09:33:24 +0200


Hi all,

I'm trying since days to get this working, and start becoming 
somewhat desperate.

I want to use Zope and ReportLab to create PDFs from within Zope. It 
works in general, but I don't manage to include images in the PDFs. 
When I do it locally (i.e. without Zope), it works fine, but I just 
don't manage to access the images in the ZODB in the right way.

Here's an example code:

*
def page1(self,c,my1,my2):
    c.setFont("Times-Roman",8)
    c.setFillColorRGB(0.1,0.1,0.1)
    c.drawString(60,775,my1)
    c.drawString(60,750,my2)
    c.drawInlineImage(my2,60,500,width=100,height=80)

def get(self):
    import PIL.Image
    from reportlab.pdfgen import canvas
    c = canvas.Canvas("/opt/zope/2-3-0/pdffiles/pdf1.pdf")
    my1=str(self.image1.id)
    my2=str(self.image1)
    page1(self,c,my1,my2)
    c.showPage()
    c.save()
*

I've tried various things in the "drawInlineImage" line, even 
directly giving the image name ('image1'), but ReportLab doesn't find 
it.

The strings my1 and my2 give the following results:
my1 (which is self.image1.id) : <Python Method Object at 8b785f0>
my2 (which is self.image1): <img src="[complete URL here]/image1" 
alt=".." height="80" width="100" border="0"/>

So, when creating the strings, the image *is* found. I just don't 
know how to correctly access it in the drawInlineImage line.

Can someone PLEASE help me? I'm really somewhat desperate by now...

Big thanks in advance,

Heiner