I'm using Apache Fop (2.1) to generate RTF documents from XML. I want the first page to have a different heading than the other pages. I have set up two simple-page-masters, one for the first page, and one for the other pages. I am running into a problem getting to page position "first". It never gets there:
<fo:page-sequence-master master-name="my-sequence">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference page-position="first" master-reference="firstPage"/>
<fo:conditional-page-master-reference page-position="rest" master-reference="otherPage"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
It always gets to the page-position="rest", even for the first page of the document. Can anybody tell me why? How can I solve this?
Fop does give me this error:
Only simple-page-masters are supported on page-sequences. Using default simple-page-master from page-sequence-master "my-sequence"
Here is the rest of my xslt:
<fo:layout-master-set>
<fo:simple-page-master master-name="firstPage"
page-height="11in" page-width="8.5in"
margin-top=".5in" margin-left="1in" margin-right="1in" margin-bottom=".5in">
<fo:region-body />
<fo:region-before region-name="firstPageBefore"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="otherPage"
page-height="11in" page-width="8.5in"
margin-top=".5in" margin-left="1in" margin-right="1in" margin-bottom=".5in">
<fo:region-body />
<fo:region-before region-name="otherPageBefore"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="my-sequence">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference page-position="first" master-reference="firstPage"/>
<fo:conditional-page-master-reference page-position="rest" master-reference="otherPage"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-sequence">
<fo:static-content flow-name="firstPageBefore">
<fo:block>First page!</fo:block>
</fo:static-content>
<fo:static-content flow-name="otherPageBefore">
<fo:block>Other page!</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body" >
<xsl:apply-templates/>
</fo:flow>
</fo:page-sequence>
I use this sample:
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="firstPage"
page-height="11in" page-width="8.5in"
margin-top=".5in" margin-left="1in" margin-right="1in" margin-bottom=".5in">
<fo:region-body background-color="red"/>
<fo:region-before region-name="firstPageBefore"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="otherPage"
page-height="11in" page-width="8.5in"
margin-top=".5in" margin-left="1in" margin-right="1in" margin-bottom=".5in">
<fo:region-body />
<fo:region-before region-name="otherPageBefore"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="my-sequence">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference page-position="first" master-reference="firstPage"/>
<fo:conditional-page-master-reference page-position="rest" master-reference="otherPage"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-sequence">
<fo:flow flow-name="xsl-region-body" >
<fo:block break-after="page">First Page</fo:block>
<fo:block break-after="page">Second Page</fo:block>
<fo:block break-after="page">Third Page</fo:block>
<fo:block>Forth Page</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
Notice I color the background of only the first page "region-body" red. I get this output with Apache FOP 2.1:
Now, if I change only to format to RTF and not PDF, I do not get the expected output. If fact to test this, I even changed the first page to 5inx5in in size. If I examine the RTF produced, there is only one page layout which is the last one.
To prove this, I change the first page to 5x5 and the remainder pages to 11x8.5 landscape and the raw RTF shows this:
{*\generator Apache XML Graphics RTF Library;} \fet0 \ftnbj \paperw15840 \paperh12240 \landscape \margt720 \margb720 \margl1440 \margr1440 \headery720 \footery720 \itap0
This is only one page template, it is not the first template. See image below, all pages landscape, no color applied at all.
This appears to be a bug or unsupported feature for Apache FOP RTF output.