如何将文本与 XSL-FO 块的底部对齐?

How to align text with the bottom of an XSL-FO block?

我正在编写一个 XSLT 脚本,它将一个 XML 输入文档转换为一个 XSL-FO 中间文档,该中间文档被转换为一个 PDF 输出文档。

我的 fo:simple-page-master 由三部分组成,页眉、正文和页脚。

<fo:layout-master-set>
    <fo:simple-page-master master-name="a4-portrait"
        page-width="210mm" page-height="297mm"
        margin-top="0mm" margin-right="12mm" margin-bottom="0mm" margin-left="12mm">
        <fo:region-body region-name="page-body" margin-top="20mm" margin-bottom="20mm"/>
        <fo:region-before region-name="page-header" extent="20mm"/>
        <fo:region-after region-name="page-footer" extent="20mm"/>
    </fo:simple-page-master>
    <fo:simple-page-master master-name="a4-landscape"
        page-width="297mm" page-height="210mm"
        margin-top="0mm" margin-right="12mm" margin-bottom="0mm" margin-left="12mm">
        <fo:region-body region-name="page-body" margin-top="20mm" margin-bottom="20mm"/>
        <fo:region-before region-name="page-header" extent="20mm"/>
        <fo:region-after region-name="page-footer" extent="20mm"/>
    </fo:simple-page-master>
</fo:layout-master-set>

这是一个简单的 hello world 页面:

<fo:page-sequence master-reference="a4-portrait">
    <!-- Page header -->
    <fo:static-content flow-name="page-header">
        <fo:block vertical-align="text-bottom">Some headline in the page header</fo:block>
        <fo:block vertical-align="text-bottom" border-bottom="0.25pt solid black"></fo:block>
    </fo:static-content>

    <!-- Page footer -->
    <fo:static-content flow-name="page-footer">
        <fo:block border-top="0.25pt solid black"></fo:block>
        <fo:block>Page <fo:page-number/></fo:block>
    </fo:static-content>

    <!-- Page body -->
    <fo:flow flow-name="page-body">
        <fo:block>Hello World!</fo:block>
    </fo:flow>
</fo:page-sequence>

如您所见,我已经尝试了 vertical-align="text-bottom" 方法。不幸的是,fo:block-元素没有对齐到上级元素的底部。

如何编写 XSLT 以使 page-header 从下到上而不是从上到下写入文本?

XSLT 2.0、XPath 2.0、Apache FOP、Saxon-HE 9.8

使用 display-align="after"(参见 https://www.w3.org/TR/xsl11/#display-align)。

display-align 适用于 fo:region-before(参见 https://www.w3.org/TR/xsl11/#fo_region-before)以及其他区域,fo:block-containerfo:external-graphicfo:instream-foreign-object , fo:inline-container, 和 fo:table-cell.

<fo:layout-master-set>
    <fo:simple-page-master master-name="a4-portrait"
        page-width="210mm" page-height="297mm"
        margin-top="0mm" margin-right="12mm" margin-bottom="0mm" margin-left="12mm">
        <fo:region-body region-name="page-body" margin-top="20mm" margin-bottom="20mm"/>
        <fo:region-before region-name="page-header" extent="20mm" display-align="after"/>
        <fo:region-after region-name="page-footer" extent="20mm"/>
    </fo:simple-page-master>
    <fo:simple-page-master master-name="a4-landscape"
        page-width="297mm" page-height="210mm"
        margin-top="0mm" margin-right="12mm" margin-bottom="0mm" margin-left="12mm">
        <fo:region-body region-name="page-body" margin-top="20mm" margin-bottom="20mm"/>
        <fo:region-before region-name="page-header" extent="20mm" display-align="after"/>
        <fo:region-after region-name="page-footer" extent="20mm"/>
    </fo:simple-page-master>
</fo:layout-master-set>