如何将内容放在文档最后一页的底部 [英] How to place content at the bottom of the last page of my document

查看:62
本文介绍了如何将内容放在文档最后一页的底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've got a document that has some content (a table containing one or more addresses) at the bottom of the last page. Until now, the table was of a standard size, so I could insert the table in a footer and attach that footer to the last page:

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

当表格具有可预测的大小时,这很有效:我设置了最后一页页脚的大小一次就完成了.

This works well when the table has a predictable size: I set the size of my last page footer once and I'm done.

但现在有一个要求使表格大小可变(在 5 到 15 厘米之间).如果我将页脚设置为 15 厘米,我会浪费很多空间.所以我想动态设置页脚大小.
我没有办法从 XML 文档中读取表格高度:默认情况下,单元格高度设置为 0,这意味着使单元格足够大以适合内容".所以我真的不能再把这张表放在页脚中了.

But now there's a request to make the table size variable (between 5 and 15 cm). If I set the footer to have an extent of 15 cm, I waste a lot of space. So I want to set the footer size dynamically.
I don't have a way to read the table height from the XML document: cell heights are set to 0 by default, meaning "make the cell large enough that the content fits". So I can't really fit this table in the footer any more.

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

My next thought was to insert the table at the end of the body region. This can be done using a footnote construct. When I place the footnote at the end of the document content, that places the table on the same page as the last text in the document.

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

遗憾的是页数必须是偶数,所以有时会在文档内容的末尾添加一个空页:

Unfortunately, the page count must be even, so sometimes an empty page is added after the end of the document content:

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

因此,如果我的内容有 3 页长,则地址表会在第 3 页的底部结束.但我需要它在第 4 页上.这种方法仅在内容以偶数页结束并且表格适合时才有效在剩下的空间里.

So if my content is 3 pages long, the address table ends up at the bottom of page 3. But I need it to be on page 4. This approach only works if the content ends on an even page AND the table fits in the space left.

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

Is there any other approach I could use to get a block of variable size at the bottom of the last page of my document?

推荐答案

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

You can force an even-page page break before the final block (the one with the footnote containing the 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 子项完全清空,以便您的输出不包含不需要的文本,即使不可见,仍然可搜索可选;如果您的格式化程序抱怨空的 fo:inline,您可以使用不间断空格 &#x00A0;.

As an aside, I think you can safely let the fo:inline child of fo:footnote completely empty, so that your output does not contain unwanted text which, even if not visible, is still searchable and selectable; should your formatter complain about the empty fo:inline, you could use a non-breaking space &#x00A0;.

这篇关于如何将内容放在文档最后一页的底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆