Whelkaholism
Whelkaholism

Reputation: 1495

XSL-FO static-content is not repeating on odd pages if no flowed content

I am creating an ID card PDF; the front contains the key info, and the back contains some variable additional details.

If there are a LOT of additional details, then multiple cards need to be generated, so the front needs to be repeated for each page the back content generates.

I have got close using odd/even selectable masters, but the front (odd) static content only shows once; it generates the additional details on even pages, but all odd pages after the first are blank; I was expecting the static content to be repeated? I have set blank-or-not-blank="any" on the odd master.

Minimal test is:

 <fo:root font-family="Arial Narrow" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<fo:layout-master-set>
  <fo:simple-page-master master-name="odd" page-width="6cm" page-height="3cm">
    <fo:region-body region-name="xsl-region-body-odd" margin-top="0cm" margin-right="0cm" margin-bottom="0cm" margin-left="0cm" />
    <fo:region-before region-name="xsl-region-before-odd" extent="100%" />
  </fo:simple-page-master>
  <fo:simple-page-master master-name="even"  page-width="6cm" page-height="3cm">
    <fo:region-body region-name="xsl-region-body-even" margin-top="0.8cm" margin-right="0cm" margin-bottom="0.8cm" margin-left="0cm" />
  </fo:simple-page-master>
  <fo:page-sequence-master master-name="master">
    <fo:repeatable-page-master-alternatives>
      <fo:conditional-page-master-reference master-reference="odd" blank-or-not-blank="any" odd-or-even="odd"/>
      <fo:conditional-page-master-reference master-reference="even" odd-or-even="even"/>
    </fo:repeatable-page-master-alternatives>
  </fo:page-sequence-master>
</fo:layout-master-set>

<fo:page-sequence master-reference="master">
  <fo:static-content flow-name="xsl-region-before-odd">
    <fo:block-container font-weight="bold" font-size="10pt" position="absolute" left="0.3cm" top="0.4cm" width="5.5cm">
      <fo:block>
        Name
      </fo:block>
    </fo:block-container>
    <fo:block-container font-weight="bold" font-size="10pt" position="absolute" left="0.3cm" top="1cm" width="5.5cm">
      <fo:block>
        Type
      </fo:block>
    </fo:block-container>
  </fo:static-content>

  <fo:flow flow-name="xsl-region-body-odd" id="flow-odd">
    <fo:block/>
  </fo:flow>
</fo:page-sequence>
<fo:page-sequence master-reference="master">
  <fo:flow flow-name="xsl-region-body-even" id="flow-even">
    <fo:table margin-left="0.2cm" table-layout="fixed" width="100%">
      <fo:table-column column-width="100%" />
      <fo:table-body>
        <fo:table-row>
          <fo:table-cell font-weight="bold" font-size="16pt">
            <fo:block>Blah blah blah</fo:block>
          </fo:table-cell>
        </fo:table-row>
        <fo:table-row>
          <fo:table-cell font-weight="bold" font-size="16pt">
            <fo:block>Blah blah blah</fo:block>
          </fo:table-cell>
        </fo:table-row>
        <fo:table-row>
          <fo:table-cell font-weight="bold" font-size="16pt">
            <fo:block>Blah blah blah</fo:block>
          </fo:table-cell>
        </fo:table-row>
        <fo:table-row>
          <fo:table-cell font-weight="bold" font-size="16pt">
            <fo:block>Blah blah blah</fo:block>
          </fo:table-cell>
        </fo:table-row>
      </fo:table-body>
    </fo:table>
  </fo:flow>
</fo:page-sequence>
</fo:root>

This generates:

enter image description here

I'm using Apache FOP via IKVM in C#.

How can I solve this?

Upvotes: 0

Views: 231

Answers (1)

Tony Graham
Tony Graham

Reputation: 8068

Repeat the fo:static-content in the second fo:page-sequence.

fo:static-content do not continue across fo:page-sequence. If you wanted to generate the name and type once in your XSL-FO, you could put them in an fo:marker, which can carry over page sequence boundaries if you set the properties the correct way.

Upvotes: 2

Related Questions