I have an fo:block that can possibly span a page. I would like to place some text like "continued" on the bottom of the first page the block is on.
The source document has a series of <step>s inside an <instructions> tag.
The only way I can see to do this is add a <step>Continued on the next page</step> into the source document at the right point, but that requires constant edits as the document is being written.
Is there a to test to see if a block spans a page?
Source document:
<recipe page-break="auto">
<instructions>
<step>The first thing to do</step>
<step>The second thing to do</step>
</instructions>
<recipe>
Relevant section of the stylesheet:
<xsl:template match="recipe">
<xsl:variable name="pbi"><xsl:choose><xsl:when test="@page-break"><xsl:value-of select="@page-break"/></xsl:when><xsl:otherwise>avoid</xsl:otherwise></xsl:choose></xsl:variable>
<xsl:variable name="pbb"><xsl:choose><xsl:when test="@page-break">always</xsl:when><xsl:otherwise>auto</xsl:otherwise></xsl:choose></xsl:variable>
<fo:block page-break-inside="{$pbi}" page-break-before="{$pbb}" margin-bottom="1.5em">
<xsl:apply-templates select="instructions/step" mode="plain"/>
</fo:block>
</xsl:template>
Thanks.
While Tony's suggestion will work, it will only work for formatters that support that construct. As he suggests, you can so the same with pure markers pulled into the footer. You might have less control in the vertical space between end of content and the footer, but the depends on your content.
You would just use retrieve-marker in the footer area, for example this:
<fo:static-content flow-name="footer">
<fo:block-container text-align="left" margin-left="1in">
<fo:block><fo:retrieve-marker retrieve-class-name="continued" retrieve-boundary="page" retrieve-position="last-starting-within-page"/>
</fo:block>
</fo:block-container>
</fo:static-content>
Now, in your flow you have some block in which you want the message to appear when that block breaks the page. You use something like this:
<fo:block-container>
<fo:marker marker-class-name="continued">I am continued on next page ...</fo:marker>
<fo:block margin-top="6pt">I am some text that will break across the page somewhere. When I do break the footer should have continued. I am some text that will break across the page somewhere. When I do break the footer should have continued. </fo:block>
<!-- More content here, whatever you need -->
</fo:block-container>
<fo:block-container keep-with-previous.within-page="always">
<fo:marker marker-class-name="continued"></fo:marker>
</fo:block-container>
The first marker inside the block-container will create a "marker" with the continued text you desire. If the page breaks inside that block, the marker is pulled into the footer area. The second marker effectively "clears" it as it has no content. It is pulled to the footer, but it is blank so nothing appears.
The result is like this, no continued text exists (pages 1, 3, 4) except where the page breaks inside the area that is marked with the continued message (page 2).