I've got a document that has some content (a table containing one or more addresses) at the bottom of the last page. Until now, the table was of a standard size, so I could insert the table in a footer and attach that footer to the last page:
<fo:page-sequence-master master-name="leaflet">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference page-position="first" master-reference="page_first_leaflet"/>
<fo:conditional-page-master-reference page-position="last" master-reference="page_last_leaflet"/>
<fo:conditional-page-master-reference master-reference="page_even_2" odd-or-even="even"/>
<fo:conditional-page-master-reference master-reference="page_odd_2_leaflet" odd-or-even="odd"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
This works well when the table has a predictable size: I set the size of my last page footer once and I'm done.
But now there's a request to make the table size variable (between 5 and 15 cm). If I set the footer to have an extent of 15 cm, I waste a lot of space. So I want to set the footer size dynamically.
I don't have a way to read the table height from the XML document: cell heights are set to 0 by default, meaning "make the cell large enough that the content fits". So I can't really fit this table in the footer any more.
My next thought was to insert the table at the end of the body region. This can be done using a footnote construct. When I place the footnote at the end of the document content, that places the table on the same page as the last text in the document.
<fo:flow flow-name="body">
<xsl:apply-templates/><!--normal chapter content is placed here-->
<fo:block>
<fo:footnote><fo:inline color="white">1</fo:inline><!--footnote number is not visible-->
<fo:footnote-body>
<fo:block>
<fo:table>
<fo:table-column column-width="20mm" column-number="1"/>
<fo:table-column column-width="200mm" column-number="2"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell column-number="2">
<fo:block>
<xsl:apply-templates select="table[1]"/><!--table that contains the addresses-->
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</fo:footnote-body>
</fo:footnote>
</fo:block>
</fo:flow>
Unfortunately, the page count must be even, so sometimes an empty page is added after the end of the document content:
<xsl:attribute name="force-page-count">end-on-even</xsl:attribute>
So if my content is 3 pages long, the address table ends up at the bottom of page 3. But I need it to be on page 4. This approach only works if the content ends on an even page AND the table fits in the space left.
Is there any other approach I could use to get a block of variable size at the bottom of the last page of my document?