Well, I have this doubt because I haven't found good documentation about it, there is a specific doubt at the moment and it is with the images.
from reportlab.lib import colors
from reportlab.lib.units import cm
from reportlab.lib.enums import TA_JUSTIFY, TA_CENTER
from reportlab.lib.pagesizes import letter, landscape
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, Image
...
#Logo
url_logo = EmpresaImagenes.objects.get(id=1).logo
if url_logo!='':
im = Image(url_logo, 3*cm, 3*cm)
im.hAlign ='RIGHT'
Story.append(im)
because if I leave only Image(url_logo)
the image it goes from the actual size, if I put Image(url_logo, 3*cm, 3*cm)
it it adjusts to 3cm x 3cm, but what if I only want to adjust the height of the image and that the width is proportional?
I would like to know if anyone also knows an API, guide, tutorial or similar (or several) that are quite complete on ReportLab? (in English or Spanish)
It's just that I'm learning and I need to do several things with ReportLab.
According to the definition of
Image
:So you might get what you want by doing this:
Even if you want to be more curious, you can install
ipython
and see how an instance ofImage
:You will notice the method definition
__init__
:You could even pass the attribute to it
hAlign
when instantiating the image:If you ask me, I always refer to the official ReportLab documentation and the User Guide