下面的代码试图调用模板,正文是一个可以跨越多个页面的重复表。 如果我尝试从这个渲染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>
答案 0 :(得分:1)
您的问题是您使用的是绝对定位的块容器:它将您的表封装在一个页面上,因此您的表不会破坏新页面。如果您没有使用绝对定位的块容器,那么您的表可以自由地使用分页和常规页面流。