1
votes

I am trying to set a footer only in the first page of a RTF document.

Approach

I defined two regions to show one in the first page and the other in the rest of pages. Once it is done, I could just remove the second footer text to achieve my goal (the generated rtf document only has two pages).

Result

Unfortunately with the transformation below I am getting the "Rest of pages footer" in both pages. It seems XSL-FO never catches the matching criteria for page-position="first". I also tried a similar approach with odd-or-even="odd" in the conditional-page-master-reference with the same result.

<fo:root>
    <fo:layout-master-set>

        <fo:simple-page-master master-name="first"
                               page-height="29.7cm" page-width="21.0cm" margin-left="2.54cm"
                               margin-right="2.54cm" margin-top="1cm" margin-bottom="2.54cm">
            <fo:region-body margin-top="1.54cm"/>
            <fo:region-after region-name="footer-first" extent="2cm" display-align="after"/>
        </fo:simple-page-master>

        <fo:simple-page-master master-name="rest"
                               page-height="29.7cm" page-width="21.0cm" margin-left="2.54cm"
                               margin-right="2.54cm" margin-top="1cm" margin-bottom="2.54cm">
            <fo:region-body margin-top="1.54cm"/>
            <fo:region-after region-name="footer-rest" extent="2cm" display-align="after" />
        </fo:simple-page-master>

        <fo:page-sequence-master master-name="document">
            <fo:repeatable-page-master-alternatives>

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

            </fo:repeatable-page-master-alternatives>
        </fo:page-sequence-master>

    </fo:layout-master-set>

    <xsl:template match="WC">
        <xsl:variable name="id.wc">id_<xsl:value-of select="normalize-space(Id/text())"/>
        </xsl:variable>
        <fo:page-sequence master-reference="document"
                          padding-top="1cm" initial-page-number="1">


            <fo:static-content flow-name="footer-first">
                <fo:block padding-top="10pt" font-size="8">
                    <fo:inline color="grey">
                        First page footer
                    </fo:inline>
                </fo:block>
            </fo:static-content>

            <fo:static-content flow-name="footer-rest">
                <fo:block text-align-last="center">Rest of pages footer</fo:block>
            </fo:static-content>

            <!-- Body continues... -->
1
I get two different footers with AH Formatter V7.1, which is what I expected from looking at your code. Which formatter are you using? - Tony Graham
I'm using Apache FOP (ver. 2.5) - DoingIt
Format to PDF and check what you get. My guess is that RTF output may not support page position templates. - Kevin Brown

1 Answers

1
votes

FOP's RTF output supports only a single page master. See https://xmlgraphics.apache.org/fop/2.6/output.html#rtf

FWIW, you can get the footers with AH Formatter using the free-but-unsupported Word output option (see https://www.antennahouse.com/microsoft-word-output):

enter image description here