[reportlab-users] valign middle and font size

Mathieu Ambrosy mathieu.ambrosy at geonov.fr
Tue Mar 20 05:47:48 EDT 2018


Hi,

I don't understand why "valign middle" don't work correctly when I set 
"FONTSIZE 14" in my table style ?
It's like "valign" position is computed with default font size 
independently of my font size ?

How to solve this ?

Regards.

#========== START ================
from reportlab.lib import colors
from reportlab.lib.pagesizes import A4
from reportlab.lib.units import cm
from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, 
Paragraph
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont

pdfmetrics.registerFont(TTFont('Calibri', 'c:/temp/calibri.ttf'))

elements = []

row1 = [
['ATTR1', 'VALUE1'],
['ATTR2', 'VALUE2'],
]

t1=Table(
row1,
style=[
('BOX',(0,0),(-1,-1),0.5,colors.black),
('GRID',(0,0),(-1,-1),0.5,colors.black),
('TEXTCOLOR',(0,0),(1,-1),colors.black),
('FONT',(0,0),(-1,-1),'Calibri'),
#========== HERE ================
#('FONTSIZE',(0,0),(-1,-1),14),
#========== HERE ================
('ALIGN',(0,0),(-1,-1),'CENTER'),
('VALIGN',(0,0),(-1,-1),'MIDDLE'),
],
colWidths=(11.2*cm, 7.8*cm),
rowHeights=(1*cm, 1.7*cm)
)

elements.append(t1)

doc = SimpleDocTemplate("c:/temp/test.pdf", pagesize=A4)
doc.build(elements)
#========== END ================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20180320/36d2dbab/attachment.html>


More information about the reportlab-users mailing list