xslt – 在xsl-fo转换中防止不需要的空白页

我正在使用xsl-fo创建带有编号页面的x文档(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>

最佳答案 我认为这是因为你有2个不同的页面序列.尝试移动< fo:block id =“last-page”/>到第一个页面序列中的流程结束并删除第二个页面序列.

例:

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