Formatting text in a table with reportlab

J

Joseph L. Casale

I sent off a msg to the reportlab list but didn't find an answer, hoping someone
here might have come across this...

I am generating a table to hold text oriented by the specification of the label
it gets printed on. I need to compress the vertical size of the table a little
more but the larger text in (1, 0) and (1, 1) as compared to the rest causes it
to migrate downwards away from the upper boundary of the cell that it's in.

Is there a better way to accomplish this or some way I can prevent the
behavior? I have tried adjusting with the rowHeight in Table() but for the
larger text in (1, 0) and (1, 1) to not migrate out of the cell, the overall
cell height has to be too large. The ('VALIGN', (1, 0), (1, 1), 'TOP') seems to
only have a minimal affect if the rowHeight is still larger than what I want
versus [None] for example.

# Define table data.
data = [
['foo', xxx, yyy, zzz, www],
['bar', ttt, uuu],
['\n'.join((iii, jjj, kkk))],
]

# Define table dimensions.
table = Table(
data,
[.625 * inch] + [None] * 4,
[None] * 3
)

# Define table styles.
table_style = [
('VALIGN', (0, 0), (-1, -1), 'BOTTOM'),
('VALIGN', (1, 0), (1, 1), 'TOP'),
('ALIGN', (0, 0), (0, 2), 'LEFT'),
('ALIGN', (1, 0), (1, 1), 'LEFT'),
('ALIGN', (2, 0), (2, 0), 'CENTER'),
('SPAN', (2, 1), (4, 1)),
('SPAN', (0, 2), (4, 2)),
('FONTSIZE', (0, 0), (0, 2), 10),
('TEXTFONT', (0, 0), (0, 2), 'Times'),
('FONTSIZE', (1, 0), (1, 1), 18),
('TEXTFONT', (1, 0), (1, 1), 'Times-Bold')
]

Thanks!
jlc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top