[reportlab-users] troubles with an image

Ángela Villota Gómez reportlab-users@reportlab.com
Mon, 01 Mar 2004 16:20:53 -0500


Hi!
I was using a flowable, an image, then i find an error! I don't know if I 
was writing something wrong, so: you can help me? again?
I import:
from reportlab.platypus import Spacer, SimpleDocTemplate, Table, TableStyle, 
Image
from reportlab.lib.units import inch
from reportlab.lib import colors
from reportlab.lib.pagesizes import landscape, A4

def getTable():
    t = Table((('','No','South','East','West'),
             ('Quarter 1',100,200,300,400),
             ('Quarter 2',100,400,600,800),
             ('Total',300,600,900,'1,200')),
             (72,36,36,36,36),
             (24, 16,16,18)
            )
    return t
def imagen():
    i= Image('logolince.jpg',width=1*inch,height=1*inch)
    i.hAlign= 'RIGTH
    return i
def run():
    doc = SimpleDocTemplate('test_platypus_tables.pdf', 
pagesize=landscape(A4))
    t = getTable()
    t.setStyle( TableStyle([ ('ALIGN', (0,0), (-1,0), 'CENTER'),
                             ('GRID', (0,0), (-1,-1), 0.25, colors.black),
                             ('LINEBELOW', (0,0), (-1,0), 2, colors.black),
                             ('LINEABOVE', (0, -1), (-1,-1), 2, 
colors.black)
                             ])
                )
    i = imagen()
     doc.build([i,t])


run()

**************el error:
File "tablas.py", line 43, in ?
    run()
  File "tablas.py", line 36, in run
    i = imagen()
  File "tablas.py", line 18, in imagen
    i= Image("logolince.jpg",width=1*inch,height=1*inch)
  File "/usr/lib/python2.2/reportlab/platypus/flowables.py", line 314, in 
__init__
    self._setup(width,height,kind,0)
  File "/usr/lib/python2.2/reportlab/platypus/flowables.py", line 326, in 
_setup
    if lazy<=0: self._setup_inner()
  File "/usr/lib/python2.2/reportlab/platypus/flowables.py", line 332, in 
_setup_inner
    (self.imageWidth, self.imageHeight) = self._img.getSize()
  File "/usr/lib/python2.2/reportlab/lib/utils.py", line 322, in getSize
    if (self._width is None or self._height is None):
AttributeError: ImageReader instance has no attribute '_width'

_________________________________________________________________
MSN Amor: busca tu ˝ naranja http://latam.msn.com/amor/