【问题标题】:Preventing unwanted blank pages in xsl-fo transformation防止 xsl-fo 转换中不需要的空白页
【发布时间】:2011-03-31 17:01:49
【问题描述】:

我正在使用 xsl-fo 创建一个带有编号页面的 pdf 文档(第 x 页,第 x 页),但是在文档末尾总是会生成一个空白页。有谁知道为什么下面的 xsl 会生成一个空白页?如果我删除 fo:block 最后一页,则不会呈现空白页。

<xsl:template match="/Report">
    <fo:root font-family="Georgia,Garamond,New York,Times,Time New Roman,Serif">
        <xsl:copy-of select="$fo-layout-master-set"/>
        <fo:page-sequence master-reference="default-page" initial-page-number="1" format="1">
            <!-- Footer content -->
            <xsl:call-template name="getStaticFooter"/>

            <fo:flow><fo:block/>
            </fo:flow>
        </fo:page-sequence>

        <fo:page-sequence master-reference="default-page">
            <!-- Footer content -->
            <xsl:call-template name="getStaticFooter"/>

            <fo:flow>

                <fo:block id="last-page"/>
            </fo:flow>
        </fo:page-sequence>
    </fo:root>
</xsl:template>

<xsl:template name="getStaticFooter">
    <fo:static-content flow-name="xsl-region-after">
        <fo:table xsl:use-attribute-sets="contentTable">
            <fo:table-column number-columns-repeated="3" width="proportional-column-width(10)"/>
            <fo:table-body>
                <fo:table-row>
                    <fo:table-cell text-align="right">
                        <fo:block>
                            <fo:inline font-size="7pt" font-weight="bold">Generated by </fo:inline>
                        </fo:block>
                        <fo:block>
                            <fo:inline font-size="7pt">Page <fo:page-number/> of <fo:page-number-citation ref-id="last-page"/></fo:inline>
                        </fo:block>
                    </fo:table-cell>
                </fo:table-row>
            </fo:table-body>
        </fo:table>
    </fo:static-content>
</xsl:template>

【问题讨论】:

  • lwburk,感谢您改进标题。

标签: xslt xsl-fo


【解决方案1】:

我认为这是因为您有 2 个不同的 fo:page-sequence。尝试将&lt;fo:block id="last-page"/&gt; 移动到第一个页面序列中的流程末尾并删除第二个fo:page-sequence

示例:

<xsl:template match="/Report">
    <fo:root font-family="Georgia,Garamond,New York,Times,Time New Roman,Serif">
        <xsl:copy-of select="$fo-layout-master-set"/>
        <fo:page-sequence master-reference="default-page" initial-page-number="1" format="1">
            <!-- Footer content -->
            <xsl:call-template name="getStaticFooter"/>    
            <fo:flow>
              <fo:block/><!-- I'm assuming this is where the actual content will exist; there's most likely a <xsl:apply-templates/> here. -->
              <fo:block id="last-page"/>
            </fo:flow>
        </fo:page-sequence>    
    </fo:root>
</xsl:template>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-01-29
    • 2017-04-15
    • 2012-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多