[reportlab-users] Appending image to Frame: no attribute 'getSpaceBefore'

Tim Roberts timr at probo.com
Tue Apr 15 13:18:41 EDT 2008


Andrés Maneiro wrote:

> Hi people,

>

> im trying append an image to a frame, something like this:

>

> / ************ BEGIN CODE ***************** /

> from reportlab.pdfgen.canvas import Canvas

> from reportlab.lib.styles import getSampleStyleSheet

> from reportlab.lib.units import inch, cm

> from reportlab.platypus import Frame, Paragraph, Image

>

> story1.append(Paragraph("This is a Heading",styleH))

> mapa = Image('prueba1.jpg', width='256', height='192')

> mapa.wrap('256', '192')

> story1.append([mapa])


But you are not appending an Image. You are appending a list containing
an image. That's why you get this:


> >>> Traceback (most recent call last):

> File "/tmp/py9217Qyl", line 30, in <module>

> f1.addFromList(story1,c)

> File

> "/usr/lib/python2.5/site-packages/reportlab/platypus/frames.py", line

> 202, in addFromList

> if self.add(head,canv,trySplit=0):

> File

> "/usr/lib/python2.5/site-packages/reportlab/platypus/frames.py", line

> 126, in _add

> s =flowable.getSpaceBefore()

> AttributeError: 'list' object has no attribute 'getSpaceBefore'


It wanted to find a flowable, but it found a list instead. Remove the
extra brackets and you should be OK.

--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the reportlab-users mailing list