XSLT / XSL-FO:页面编号从第2页开始

时间:2012-04-02 16:21:27

标签: xslt xsl-fo apache-fop

我正在使用XSLT和XSL-FO来创建文档。并且要求是:在文档中,页码应该从第2页开始(第2页上的数字应该是1)。

在layout-master-set中我创建了2个simple-page-master并尝试以下方式:

<fo:layout-master-set>
    <fo:simple-page-master master-name="cover" page-height="11in" page-width="8.5in">
        <fo:region-body margin="0.1in 1.0in 0.45in 1.0in"/>
    </fo:simple-page-master>

    <fo:simple-page-master master-name="master" page-height="11in" page-width="8.5in">
        <fo:region-body margin="0.1in 1.0in 0.45in 1.0in"/>
        <fo:region-after  region-name="footer-first1" extent="1.2in"/>
    </fo:simple-page-master>


    <fo:page-sequence-master master-name="CoverPage1">
        <fo:repeatable-page-master-alternatives>
            <fo:conditional-page-master-reference master-reference="cover" page-position="first" />
        </fo:repeatable-page-master-alternatives>
    </fo:page-sequence-master>


    <fo:page-sequence-master master-name="CoverPage">
        <fo:repeatable-page-master-alternatives>
            <fo:conditional-page-master-reference master-reference="cover" page-position="first" />
            <fo:conditional-page-master-reference master-reference="master"  page-position="rest"/>
        </fo:repeatable-page-master-alternatives>
    </fo:page-sequence-master>
</fo:layout-master-set>

<fo:page-sequence master-reference="CoverPage1">
    <fo:flow flow-name="xsl-region-body">
        <xsl:apply-templates/>
    </fo:flow>
</fo:page-sequence>

<fo:page-sequence initial-page-number="1" master-reference="CoverPage">
    <fo:static-content flow-name="footer-first1">
        <xsl:call-template name="footer1"/>
    </fo:static-content>
    <fo:flow flow-name="xsl-region-body">
        <xsl:apply-templates/>
    </fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>

和页脚:

<xsl:template name="footer1"> 
  <fo:block font-family="Times" text-align="center" font-size="10.5pt" space-before="45pt">
    <fo:block><fo:leader leader-length="6.8in" leader-pattern="space"/><fo:page-number/></fo:block>
  </fo:block>
</xsl:template>

当我删除

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

来自<fo:page-sequence-master master-name="CoverPage">

FOP引发以下异常:

  

FOPException:在page-sequence-master“CoverPage”中耗尽的子序列无法解析

关于如何处理这个的任何想法或帮助?

0 个答案:

没有答案