Search code examples
xsl-foantenna-house

How to horizontally align text within a rotated table cell in XSL-FO?


With Antenna House 5.3 I haven't found how to create a table cell that is rotated 90 degrees "left aligned" (so, on the bottom vertically on the page) and "vertically centered" (in the middle horizontally on the page). I have tried all the combinations of text-align display-align that I think I can, but the result is still "top aligned" (on the bottom vertically, and on the left horizontally).

Do you know how to make text left aligned and vertically centered, in a rotated table cell? Here is an example of a cell:

<fo:table-cell display-align="after">
  <fo:block-container reference-orientation="90" display-align="center">
    <fo:block>Text</fo:block>
  </fo:block-container>
</fo:table-cell>

The result is that the text is not centered left-to-right on the page.


Solution

  • Using AH Formatter V6.6 (I don't have V5.3 installed), if you give the table column a width (using fo:column and column-width) and set height="100%" on the fo:block-container, then the formatter has more to work with so that it can center the text in the column.

    The screenshot below is from the AH Formatter GUI with the 'Show Border' option enabled so that you can see the extent of the areas and see the (rotated) height of the fo:block-container in the second table header cell.

    Screenshot of table in AH Formatter GUI

    <fo:table start-indent="0" end-indent="0">
      <fo:table-column column-width="50pt" />
      <fo:table-column column-width="50pt" />
      <fo:table-header>
        <fo:table-row>
          <fo:table-cell display-align="after" padding="6pt">
            <fo:block-container reference-orientation="90" display-align="center">
              <fo:block>Text</fo:block>
            </fo:block-container>
          </fo:table-cell>
          <fo:table-cell display-align="after" padding="6pt">
            <fo:block-container height="100%" reference-orientation="90" display-align="center">
              <fo:block>Text</fo:block>
            </fo:block-container>
          </fo:table-cell>
        </fo:table-row>
      </fo:table-header>
      <fo:table-body>
        <fo:table-row>
          <fo:table-cell padding="6pt">
            <fo:block>Text</fo:block>
          </fo:table-cell>
          <fo:table-cell padding="6pt">
            <fo:block>Text</fo:block>
          </fo:table-cell>
        </fo:table-row>
      </fo:table-body>
    </fo:table>