Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rotated text in table cell rendered above cell not within

I have the following template to generate a table defined:

<xsl:template name="CreateTable">
    <fo:block>
        <fo:table border-style="solid" table-layout="fixed">
            <fo:table-body>
                <fo:table-row>
                    <xsl:for-each select="Table/Head/Cell">
                        <fo:table-cell border-style="solid">
                            <fo:block><xsl:value-of select="." /></fo:block>
                        </fo:table-cell>
                    </xsl:for-each>
                </fo:table-row>
                <xsl:for-each select="Table/Row">
                    <fo:table-row>
                        <xsl:for-each select="Cell">
                            <fo:table-cell  border-style="solid">
                                <fo:block><xsl:value-of select="."/></fo:block>
                            </fo:table-cell>
                        </xsl:for-each>
                    </fo:table-row>
                </xsl:for-each>
            </fo:table-body>
        </fo:table>
    </fo:block>
    <fo:block margin-top="10pt"/>
</xsl:template>

Now I want to rotate the text in the first row by 90 degrees so it is to be read from bottom up.

The best solution I came up with is to:

  • set a reference-orientation="0" on <fo:table>:

    <fo:table border-style="solid" table-layout="fixed" reference-orientation="0">
    
  • enclose the <fo:block>...</fo:block> within the <fo:table-cell> with a <fo:block-container> rotated by 90 degrees:

    <fo:table-cell border-style="solid">
        <fo:block-container reference-orientation="90">
            <fo:block><xsl:value-of select="." /></fo:block>
        </fo:block-container>
    </fo:table-cell>
    

The text is rotate but the height of the first row is effectively 0 and the text is displayed above the table overlaying previous text:

rotated text overlaying previous text

When defining a specific height for the cells of the first row, the text is still before the table and not within the first row:

rotated text overlaying previous text and empty first row

How can I position the text within the cells of the first row and have the height of the row computed automatically depending on the longest text within the row?

like image 347
Torbjörn Avatar asked Jan 16 '18 20:01

Torbjörn


1 Answers

Text displaying outside the table: the fo:block inside the table cell may be inheriting settings like a left margin from an enclosing block.

The cell height problem I haven't seen before, in Antennahouse Formatter you can rotate cell content and IIRC the cell will be resized appropriately.

like image 151
Hobbes Avatar answered Oct 21 '22 10:10

Hobbes