[reportlab-users] Image within a table - Preserve Aspect Ratio

Pizzolato, Larissa (EC) larissa.pizzolato at canada.ca
Fri Feb 22 15:56:04 EST 2019


Hi all,

I would like to add an image within a table (example below - maxIMAGE), but would like the aspect ratio to be preserved.
            from reportlab import platypus as platy
maxIMAGE = platy.Image(maxIMAGE_path,2.2*inch, 2.2*inch)
maxIMAGE_table = Table([[maxIMAGE]],2.3*inch, 2.3*inch, style=[('GRID',(0,0),(0,0),.5, 'black'), ('BACKGROUND',(0,0),(0,0), "white"),('ALIGN',(0,0),(0,0), 'CENTER'),('VALIGN',(0,0),(0,0), 'MIDDLE')])


However, when I try doing preserveAspectRatio=True, I receive the following error:
TypeError: __init__() got an unexpected keyword argument 'preserveAspectRatio'

I've also tried the solution listed here: https://stackoverflow.com/questions/5327670/image-aspect-ratio-using-reportlab-in-python with no success.

Is there another way to render the image into the table that has this capability?

Any ideas?

Cheers!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20190222/2493d331/attachment.html>


More information about the reportlab-users mailing list