[Zope3-Users] Building PDF files using reportlab, with image objects in Zope3

Adam Summers adam at 4js.com.au
Mon Jan 2 22:30:25 EST 2006


Hi,

I'm trying to build a report using zope3 + reportlab 1.20 that I want to 
contain some images from a container (which in the code below is called 
'item').

Has anyone done this? Can they suggest a technique?

Trying the following:
            images = []
            for docpage in item.values():
                f = tempfile.TemporaryFile()
                f.write(docpage.data)
                width, height = docpage.getImageSize()
                images.append( Image(f, width=width, height=height) )


Only gets me as far as an error (when the images list is placed on the 
list containing the document structure):
  File "/home/Adam/z3/Zope3/src/zope/component/site.py", line 75, in 
queryMultiAdapter
    default)
  File "/home/Adam/z3/Zope3/src/zope/interface/adapter.py", line 475, in 
queryMultiAdapter
    return factory(*objects)
  File "/home/Adam/z3/products/ccard/pdf/card.py", line 58, in __init__
    images.append( Image(f, width=width, height=height) )
  File 
"/usr/lib/python2.4/site-packages/reportlab/platypus/flowables.py", line 
318, in __init__
    self._setup(width,height,kind,0)
  File 
"/usr/lib/python2.4/site-packages/reportlab/platypus/flowables.py", line 
327, in _setup
    if lazy<=0: self._setup_inner()
  File 
"/usr/lib/python2.4/site-packages/reportlab/platypus/flowables.py", line 
334, in _setup_inner
    if img: self.imageWidth, self.imageHeight = img.getSize()
  File "/usr/lib/python2.4/site-packages/reportlab/lib/utils.py", line 
530, in getSize
    if (self._width is None or self._height is None):
AttributeError: ImageReader instance has no attribute '_width'

       Has anyone done what I want to? How? Any help would be much 
appreciated.

Regards,
Adam




More information about the Zope3-users mailing list