简体   繁体   中英

XSL-FO Ignore the last page break but how?

another question for the XSL-FO guys… Well I found out how do to a page break with

<fo:block page-break-after="always"> </fo:block>

This is working fine, but it adds me an empty page at the end of the document. I also tried it with “before” bit without success and “auto” well this is not what I am searching. Is there a possibility to count the breaks, or do the breaks until the last page and remove the last break or something like that. I found nothing on the reference, but maybe i`m searching for the wrong thing. Thanks in advance

http://www.w3.org/TR/xsl11/#page-break-inside

You can do it in your XSLT. Instead of <fo:block page-break-after="always"> </fo:block> , you can do:

<fo:block>
  <xsl:if test="position() != last()">
    <xsl:attribute name="page-break-after">always</xsl:attribute>
  </xsl:if>
</fo:block>

This assumes that in your XSLT you're selecting all of the elements/attributes that produce the fo:block and processing them in one go (ie, so they are all part of the same context so that the last one really is in the last() position). If not, you'd have to find some other way for determining when to not generate the page-break-after attribute.

(Note that page-break-after is a shorthand for break-after="page" . See http://www.w3.org/TR/xsl11/#page-break-after )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM