Search code examples
xsl-fo

Layout change after page 2


I need to produce invoices that have a payment slip on the bottom of the first page. On the back of that first page the text must not go into the payment slip area on the front. From the the next page on, the whole page size must be used for the text.

Is this possible with xsl-fo? I couldn't figure a way to do this.


Solution

  • You would use an fo:page-sequence-master. See

    Something like:

    <fo:page-sequence-master master-name="psm">
      <fo:single-page-master-reference master-reference="page1"/>
      <fo:single-page-master-reference master-reference="page2"/>
      <fo:repeatable-page-master-reference master-reference="the-rest"/>
    </fo:page-sequence-master>
    

    where page is the fo:simple-page-master for the first page, page2 is for the second page, and the-rest is for the rest.

    You'd have to set the margin-bottom on either page2 or its fo:region-body so that no content goes behind the payslip.

    The most portable way to do the payslip on page1 would be to put its content in the fo:static-content for the fo:region-after of page1. If your formatter supports multiple fo:region-body then you could put the content in a second fo:flow to flow into a second fo:region-body. If you are using AH Formatter, you could use either of those techniques or you could put the payslip content in an fo:float and make it float to the bottom of the page.