如何将内容放在文档最后一页的底部

How to place content at the bottom of the last page of my document

我有一份文档,在最后一页的底部有一些内容(table 包含一个或多个地址)。 到目前为止,table 是标准尺寸,所以我可以将 table 插入页脚并将该页脚附加到最后一页:

<fo:page-sequence-master master-name="leaflet">
                <fo:repeatable-page-master-alternatives>
                    <fo:conditional-page-master-reference page-position="first" master-reference="page_first_leaflet"/>
                    <fo:conditional-page-master-reference page-position="last" master-reference="page_last_leaflet"/>
                    <fo:conditional-page-master-reference master-reference="page_even_2" odd-or-even="even"/>
                    <fo:conditional-page-master-reference master-reference="page_odd_2_leaflet" odd-or-even="odd"/>
                </fo:repeatable-page-master-alternatives>
            </fo:page-sequence-master>

当 table 具有谓词 table 大小时,这很有效:我设置了一次最后一页页脚的大小,然后就完成了。

但现在有一个要求使 table 大小可变(在 5 到 15 厘米之间)。如果我将页脚设置为 15 厘米,我会浪费很多 space。所以我想动态设置页脚大小。
我无法从 XML 文档中读取 table 高度:单元格高度默认设置为 0,即 "make the cell large enough that the content fits"。所以我真的不能再把这个 table 放在页脚中了。

我的下一个想法是在正文区域的末尾插入 table。 这可以使用脚注结构来完成。当我将脚注放在文档内容的末尾时,会将 table 放置在与文档中最后一个文本相同的页面上。

            <fo:flow flow-name="body">
                <xsl:apply-templates/><!--normal chapter content is placed here-->
                    <fo:block>
                        <fo:footnote><fo:inline color="white">1</fo:inline><!--footnote number is not visible-->
                            <fo:footnote-body>
                                <fo:block>
                                    <fo:table>
                                        <fo:table-column column-width="20mm" column-number="1"/>
                                        <fo:table-column column-width="200mm" column-number="2"/>                                   
                                        <fo:table-body>
                                            <fo:table-row>
                                                <fo:table-cell column-number="2">
                                                    <fo:block>
                                                        <xsl:apply-templates select="table[1]"/><!--table that contains the addresses-->
                                                    </fo:block>
                                                </fo:table-cell>
                                            </fo:table-row>
                                        </fo:table-body>
                                    </fo:table>
                                </fo:block>
                            </fo:footnote-body>
                        </fo:footnote>
                    </fo:block>
        </fo:flow>

不幸的是,页数必须是偶数,所以有时会在文档内容结束后添加一个空页:

<xsl:attribute name="force-page-count">end-on-even</xsl:attribute>

因此,如果我的内容有 3 页长,地址 table 会在第 3 页的底部结束。但我需要它在第 4 页。这种方法仅在内容结束于偶数页 AND table 适合 space 左侧。

是否有任何其他方法可以用来在我的文档最后一页的底部获得一个可变大小的块?

您可以在最后一个块(脚注包含 table "footer" 的块)之前强制使用 偶数页分页符

        <fo:block break-before="even-page">
            <fo:footnote><fo:inline color="white">1</fo:inline><!--footnote number is not visible-->
                <fo:footnote-body>
                    <fo:block>
                        <fo:table>
                            <fo:table-column column-width="20mm" column-number="1"/>
                            <fo:table-column column-width="200mm" column-number="2"/>
                            <fo:table-body>
                                <fo:table-row>
                                    <fo:table-cell column-number="2">
                                        <fo:block>
                                            this is the footnote table
                                        </fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                            </fo:table-body>
                        </fo:table>
                    </fo:block>
                </fo:footnote-body>
            </fo:footnote>
        </fo:block>

顺便说一句,我认为您可以安全地让 fo:footnotefo:inline 子级完全为空,这样您的输出就不会包含不需要的文本,即使不可见,这些文本仍然是 可搜索选择table;如果您的格式化程序抱怨空的 fo:inline,您可以使用不间断的 space &#x00A0;.