Upon finding the "keep-together" attribute, and needing to not page break inside a row I added keep-together="always"
on every table-row element in my xslt.
Is there a nicer way of achieving the same effect? It seems a bit hacky.
(ps. I will accept "no" as an answer if no one provides a better one, provided some kind of explanation is proffered.)
I have used the following three methods to keep table rows together with some success:
<tr keep-together.within-page="always">
...
</tr>
<tr keep-with-next.within-page="always">
<td keep-together.within-page="always">...</td>
...
</tr>
<tr>...</tr>
<tr>...</tr>
<tr keep-with-previous.within-page="always">
<td keep-together.within-page="always">...</td>
...
</tr>
Though you have to be careful - if the row or cell would span more than one page of a generated document, you will loose the bottom of that page off the bottom!
keep-together="always"
is dangerous because that's a compound property that also indirectly sets keep-together.within-line="always"
(prohibiting line breaks inside a table-cell). You should use keep-together.within-column="always"
instead. But specifying that on a table-row is actually the way to go. Nothing hacky about it.
See also: http://www.w3.org/TR/xsl11/#datatype
This answer solved my problem of a table row that was flowing over a page break when i needed to lock the table together. i used the <fo:table keep-together="always"></fo:table>
Thanks.
With an XSL formatter that handles integer keeps, you can use an integer value so that the formatter will try to keep the row together but will break the row rather than run off the end of the page. However, this question is tagged for FOP, and FOP's compliance page currently states that it has limited support for integer keeps (http://xmlgraphics.apache.org/fop/compliance.html#fo-property-keep-together), so YMMV.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With