1

下面的代码尝试调用模板,body 是一个可以跨越多个页面的重复表。如果我尝试从中呈现 PDF,它只会给出一个溢出的页面并且不会进入下一页。关于我在这里做错了什么的任何想法?

    <xsl:template match="/">
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
        <!-- ================================= OVERALL LAYOUT======================= -->
        <fo:layout-master-set>
            <!-- ========= LAYOUT ========= -->
            <fo:simple-page-master master-name="any-page" page-width="210mm" page-height="296mm" margin-left="0mm" margin-top="0mm">
                <fo:region-body margin-bottom="2.1cm" margin-top="5.40cm" margin-left="0cm" margin-right="0cm" padding="0cm"/>
                <fo:region-before region-name="header" extent="85mm"/>
                <fo:region-after region-name="footer" extent="81mm"/>
            </fo:simple-page-master>
            <!-- ========= OVERALL LAYOUT ========= -->
            <fo:page-sequence-master master-name="A4">
                <fo:repeatable-page-master-alternatives>
                    <fo:conditional-page-master-reference master-reference="any-page" page-position="any"/>
                </fo:repeatable-page-master-alternatives>
            </fo:page-sequence-master>
        </fo:layout-master-set>
        <!-- =================================CONTENT TEMPLATE CALL================================= -->
        <xsl:for-each select="//XY">
            <fo:page-sequence master-reference="A4">
                <!-- ========= HEADER ========= -->
                <fo:static-content flow-name="header">
                    <fo:block break-before="page"/>
                    <xsl:choose>
                        <xsl:when test="XY = 'XY ">
                            <xsl:call-template name="XY_HEADER"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:call-template name="YY_HEADER"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </fo:static-content>
                <!-- ========= FOOTER ========= -->
                <fo:static-content flow-name="footer">
                    <xsl:choose>
                        <xsl:when test="XY = 'XY' ">
                            <xsl:call-template name="XY_FOOTER"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:call-template name="YY_FOOTER"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </fo:static-content>
                <!-- ========= BODY ========= -->
                <fo:flow flow-name="xsl-region-body">
                    <xsl:choose>
                        <xsl:when test="XY = 'XY' ">
                            <xsl:call-template name="XY_BOD"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:call-template name="YY_BOD"/>
                        </xsl:otherwise>
                    </xsl:choose>
                    <xsl:if test="position()=last()">
                        <fo:block id="last-page"/>
                    </xsl:if>
                </fo:flow>
            </fo:page-sequence>
        </xsl:for-each>
    </fo:root>
</xsl:template>
    <xsl:template name="XY_BODY" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <fo:block-container position="absolute" left="5mm" top="95mm" height="200mm" width="200mm">
        <fo:block text-align="left" font-size="3mm" page-break-before="always">
            <fo:table table-layout="fixed" height="10.4cm" width="27cm" top="0.7cm" left="0cm" padding="0mm" position="absolute" font-size="10">
                <fo:table-body>
                ..
                ...
                </fo:table-body>
            </fo:table>
        </fo:block>
    </fo:block-container>
    <fo:block-container position="absolute" left="5mm" top="286mm" height="5mm" width="200mm">
        <fo:block padding-left="1mm" text-align="right">
            <fo:page-number/> of <fo:page-number-citation ref-id="last-page"/>
        </fo:block>
    </fo:block-container>
</xsl:template>
4

1 回答 1

1

您的问题是您使用的是绝对定位的块容器:它将您的表格封装在一个页面上,因此您的表格不会中断到新页面。如果您不使用绝对定位的块容器,那么您的表格将可以自由地进行分页和常规页面流。

于 2013-09-09T16:13:19.017 回答