0
votes

I want my FOP to generate a pdf with a different body section for the last page. I tried to implement this behaviour like this:

<xsl:template match="/fatture">
  <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

    <fo:layout-master-set>
      <fo:simple-page-master master-name="main" page-height="297mm" page-width="210mm"
                             margin-top="0mm" margin-bottom="5mm" margin-left="5mm" margin-right="5mm">
        <fo:region-body margin-top="110mm" margin-bottom="75mm"/>
        <fo:region-before extent="110mm"/>
        <fo:region-after extent="75mm"/>
      </fo:simple-page-master>

      <fo:simple-page-master master-name="main-other" page-height="297mm"
                             page-width="210mm" margin-top="0mm" margin-bottom="5mm" margin-left="5mm"
                             margin-right="5mm">
        <fo:region-body margin-top="110mm" margin-bottom="75mm"
                        region-name="xsl-region-body"/>
        <fo:region-before extent="110mm" region-name="xsl-region-before"/>
        <fo:region-after extent="75mm" region-name="xsl-region-footer"/>
      </fo:simple-page-master>
      <fo:simple-page-master master-name="main-last" page-height="297mm"
                             page-width="210mm" margin-top="0mm" margin-bottom="5mm" margin-left="5mm"
                             margin-right="5mm">
        <fo:region-body margin-top="110mm" margin-bottom="75mm"
                        region-name="xsl-region-body-last"/>
        <fo:region-before extent="110mm" region-name="xsl-region-before"/>
        <fo:region-after extent="75mm" region-name="xsl-region-footer"/>
      </fo:simple-page-master>

      <fo:page-sequence-master master-name="sintetica">
        <fo:repeatable-page-master-alternatives>
          <fo:conditional-page-master-reference master-reference="main-last" 
                                                page-position="last"/>
          <fo:conditional-page-master-reference master-reference="main-last"/>
        </fo:repeatable-page-master-alternatives>
      </fo:page-sequence-master>

    </fo:layout-master-set>
    <xsl:for-each select="fattura">
      <fo:page-sequence master-reference="sintetica">
        <xsl:call-template name="main-document.header"/>
        <xsl:call-template name="main-document.footer"/>
        <xsl:call-template name="main-document.body"/>
        <xsl:call-template name="main-document-last.body"/>
      </fo:page-sequence>
    </xsl:for-each>

    <!--        
    -->
  </fo:root>
</xsl:template>

But I have an error I think in the page-sequence section because I try to call 2 different body. The error is:

Flow 'xsl-region-body' does not map to the region-body in page-master 'main-last'. FOP presently does not support this.

Any idea how to solve my problem? If I use in the page sequence the flow tag can I declare 2 body?

1

1 Answers

0
votes

There is a typo in your first fo:conditional-page-master-reference - both the master-reference attributes are set to "main-last" - does this fix the issue?

Additionally, maybe this other question already provides a fitting answer? Link: How to detect the last page of the document?