【问题标题】:XSL-FO footer only in first page (2-page rtf doc)XSL-FO 页脚仅在第一页(2 页 rtf doc)
【发布时间】:2021-09-19 06:41:13
【问题描述】:

我试图只在 RTF 文档的第一页设置页脚。

接近

我定义了两个区域,一个在第一页显示,另一个在其余页显示。 完成后,我可以删除第二个页脚文本以实现我的目标(生成的 rtf 文档只有两页)。

结果

不幸的是,通过下面的转换,我在两个页面中都得到了 “其余页脚”。似乎 XSL-FO 从未捕获 page-position="first" 的匹配条件。 我还尝试了在 conditional-page-master-reference 中使用 odd-or-even="odd" 的类似方法,结果相同。

<fo:root>
    <fo:layout-master-set>

        <fo:simple-page-master master-name="first"
                               page-height="29.7cm" page-width="21.0cm" margin-left="2.54cm"
                               margin-right="2.54cm" margin-top="1cm" margin-bottom="2.54cm">
            <fo:region-body margin-top="1.54cm"/>
            <fo:region-after region-name="footer-first" extent="2cm" display-align="after"/>
        </fo:simple-page-master>

        <fo:simple-page-master master-name="rest"
                               page-height="29.7cm" page-width="21.0cm" margin-left="2.54cm"
                               margin-right="2.54cm" margin-top="1cm" margin-bottom="2.54cm">
            <fo:region-body margin-top="1.54cm"/>
            <fo:region-after region-name="footer-rest" extent="2cm" display-align="after" />
        </fo:simple-page-master>

        <fo:page-sequence-master master-name="document">
            <fo:repeatable-page-master-alternatives>

                <fo:conditional-page-master-reference page-position="first" master-reference="first" />
                <fo:conditional-page-master-reference page-position="rest" master-reference="rest" />

            </fo:repeatable-page-master-alternatives>
        </fo:page-sequence-master>

    </fo:layout-master-set>

    <xsl:template match="WC">
        <xsl:variable name="id.wc">id_<xsl:value-of select="normalize-space(Id/text())"/>
        </xsl:variable>
        <fo:page-sequence master-reference="document"
                          padding-top="1cm" initial-page-number="1">


            <fo:static-content flow-name="footer-first">
                <fo:block padding-top="10pt" font-size="8">
                    <fo:inline color="grey">
                        First page footer
                    </fo:inline>
                </fo:block>
            </fo:static-content>

            <fo:static-content flow-name="footer-rest">
                <fo:block text-align-last="center">Rest of pages footer</fo:block>
            </fo:static-content>

            <!-- Body continues... -->

【问题讨论】:

  • 我使用 AH Formatter V7.1 获得了两个不同的页脚,这是我在查看您的代码时所期望的。您使用的是哪种格式化程序?
  • 我使用的是 Apache FOP(2.5 版)
  • 格式化为 PDF 并检查你得到了什么。我的猜测是 RTF 输出可能不支持页面位置模板。

标签: xslt footer rtf xsl-fo apache-fop


【解决方案1】:

FOP 的 RTF 输出仅支持单页母版。见https://xmlgraphics.apache.org/fop/2.6/output.html#rtf

FWIW,您可以使用 AH Formatter 使用免费但不受支持的 Word 输出选项获取页脚(请参阅 https://www.antennahouse.com/microsoft-word-output):

【讨论】:

  • 感谢 Tony 提供的信息,非常感谢。
猜你喜欢
  • 1970-01-01
  • 2012-07-28
  • 2021-04-24
  • 2015-12-18
  • 1970-01-01
  • 2015-04-06
  • 2019-10-16
  • 1970-01-01
  • 2015-02-01
相关资源
最近更新 更多