首页 > 解决方案 > 如何在 XSL-FO 中的旋转表格单元格中水平对齐文本?

问题描述

使用 Antenna House 5.3,我还没有找到如何创建一个旋转 90 度的表格单元格“左对齐”(因此,在页面的垂直底部)和“垂直居中”(在页面的中间水平)。我已经尝试了所有我认为可以的 text-align display-align 组合,但结果仍然是“顶部对齐”(垂直底部,水平左侧)。

您知道如何在旋转的表格单元格中使文本左对齐并垂直居中吗?这是一个单元格的示例:

<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>

结果是文本不在页面上从左到右居中。

标签: xsl-foantenna-house

解决方案


使用 AH Formatter V6.6 (我没有安装 V5.3),如果您为表格列指定宽度(使用fo:columnand column-width)并设置height="100%"fo:block-container在列中。

下面的屏幕截图来自启用了“显示边框”选项的 AH Formatter GUI,以便您可以查看区域的范围并查看fo:block-container第二个表格标题单元格中的(旋转)高度。

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>

推荐阅读