[reportlab-users] Vertical Align in Tables With Large Fonts.

jpywtora at calpoly.edu jpywtora at calpoly.edu
Wed Dec 8 17:23:07 EST 2004


On Friday 03 December 2004 10:05 pm, sp3ktr wrote:
> On Fri, 3 Dec 2004 10:24:09 -0800, jpywtora at calpoly.edu
> <jpywtora at calpoly.edu> wrote:
>  
>
> > If the contents are not in a Paragraph flowable, try using one.  Assuming
> > this is a text cell.
>
> They are text cells.  I tried it with a Paragraph object but to no avail.
>
> > Outside of this more than likely would need to see a small code snippet.
>
> Here is a quick example. In the pdf, both the text cells and the
> Paragraph flowable still sit to the bottom of the fields (i'm assuming
> the VALIGN directive in the table cell should align the whole
> Paragraph object?):

Ok first the code that shows VALIGN working.  Quick answer is your table row 
heights were two small.
data = (
    ('Nov', 'Dec'),
    ('Nov', Paragraph('<fontsize="20">test</font>', styleSheet['Normal']))
)
t1 = Table(
    data,
    (200, 200),
    (100, 100),
    (
        ('GRID', (0, 0),(-1, -1),1, colors.red),
        ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
        ('SIZE', (0, 0), (-1, -1), 20)
    )
)
story.append(t1)

I chose to put the table style right in the constructor which is my typical 
way.  Actually I put the styles in a config module and just import them where 
I want them.  When you set up the table...

t1 = Table(data,(200,200),(40))  <== Your code

Your forst row has a height of 40, but the second is unspecified.  Which is ok 
in some conditions.  However, in your case neither was enough to see the 
VALIGN working.  I believe without my changes the cell with the paragraph was 
correct and in the middle, however due to the cell size along with padding it 
was hard to actually see it.  So, you may need to specify something more than 
the default for the padding which is large enough to cause the frustration 
you may have experienced.

Johnny P
-- 
Windows
Start Here
Frustrating Hanging Crashing
Blue Screen of Death
Reboot


More information about the reportlab-users mailing list