Search code examples
pdf-generationxsl-foapache-fop

Alignment of table content of different font-size


I'm filling a table with different size text (left column Helvetica 6pt, right column Times 8pt), but the baselines of the texts do not align - the left text is visibly higher than the one in the right column. How do I get it nice? Using FOP 2.1.

One way would be to add line-height=... but then what value would I have to set line-height to in order to get the same vertical spacing that I have now?

Isn't there a more generic way?

    <fo:block-container position="absolute" top="27mm" left="125mm" width="75mm" font-family="Times" font-size="8pt">
        <fo:table table-layout="fixed">
            <fo:table-column column-width="2.7cm"/>
            <fo:table-column column-width="4cm"/>
            <fo:table-body>
                <fo:table-row>
                    <fo:table-cell>
                        <fo:block margin-top="12pt" font-size="6pt" font-family="Helvetica">Contact:</fo:block>
                    </fo:table-cell>
                    <fo:table-cell>
                        <fo:block margin-top="12pt">Normally me</fo:block>
                    </fo:table-cell>
                </fo:table-row>
                <fo:table-row>
                    <fo:table-cell>
                        <fo:block font-size="6pt">&#xa0;</fo:block>
                    </fo:table-cell>
                    <fo:table-cell>
                        <fo:block>Manager</fo:block>
                    </fo:table-cell>
                </fo:table-row>
                <fo:table-row>
                    <fo:table-cell>
                        <fo:block font-size="6pt" font-family="Helvetica">email:</fo:block>
                    </fo:table-cell>
                    <fo:table-cell>
                        <fo:block>dings@bums</fo:block>
                    </fo:table-cell>
                </fo:table-row>
            </fo:table-body>
        </fo:table>
    </fo:block-container>

Solution

  • More research and a comment putting more light: line-height="inherit"

    <fo:block font-size="6pt" font-family="Helvetica" line-height="inherit">
    

    in all the blocks of the left column does it in this case without specifying an explicit line-size anywhere.