2
votes

I can't find a way to prevent a page break inside a table in the RTF output.

I've tried a lot of combinations of keep-together / keep-with-next but nothing worked for me. The actual version has a parent fo:block with the attribute keep-together.within-page="always" including the whole table.

The problem only occurs when a RTF is generated. The PDF is correct and no page break inside a table exists. The table has a header-row and 3 data-rows. In the RTF there is a page-break after the header-row and the first 2 data-rows. On the next page the header is repeated and the last data-row is generated.

It's very important that the tables don't include a page-break.

Here is the relevant XSLT-Stylesheet code:

<fo:block keep-together.within-page="always" > 
        <xsl:for-each select="block"> 
            <xsl:call-template name="drawData"></xsl:call-template> 
        </xsl:for-each> 
        <fo:table text-align="center"> 
            <xsl:for-each select="row[@type='declare'][1]/column"> 
                <fo:table-column column-number="position()" border-style="solid" border-color="#000000" border-width="0.5pt"> 
                    <xsl:attribute name="column-width"><xsl:value-of select="@width"/></xsl:attribute> 
                </fo:table-column> 
            </xsl:for-each> 
            <xsl:if test="row[@type='header']"> 
                <fo:table-header> 
                    <fo:table-row keep-together.within-page="2" background-color="#0000FF" color="#FFFFFF"> 
                        <xsl:for-each select="row[@type='header'][1]/column/block"> 
                            <fo:table-cell border-style="solid" border-color="#000000" border-width="0.5pt"> 
                                <xsl:attribute name="number-columns-spanned"> 
                                    <xsl:value-of select="count(../../../row[@type='declare']/column) div count(../../../row[@type='declare'])"/> 
                                </xsl:attribute> 
                                <xsl:call-template name="drawData"></xsl:call-template> 
                            </fo:table-cell> 
                        </xsl:for-each> 
                    </fo:table-row> 
                </fo:table-header>       
            </xsl:if> 
            <fo:table-body>
                <xsl:for-each select="row[not(@type='header')]"> 
                    <fo:table-row keep-together.within-page="2"> 
                        <xsl:for-each select="column/block"> 
                            <fo:table-cell border-style="solid" border-color="#000000" border-width="0.5pt"> 
                                <xsl:call-template name="drawData"></xsl:call-template> 
                            </fo:table-cell> 
                        </xsl:for-each> 
                    </fo:table-row> 
                </xsl:for-each>
            </fo:table-body> 
        </fo:table>
    </fo:block> 

A screenshot of the relevant table: Document View

1
There is not really such a thing as "XSL-FO 2.0". Do you mean that you use Apache FOP 2.0?mzjn

1 Answers

2
votes

At the moment (FOP version 2.1), the RTF output has a few limitations compared to the PDF output; in particular, it does not support keep properties.

The linked page states that

RTF output is currently unmaintained

and keeps are

supported by the RTF library but not tied into the RTFHandler

so, while it is probably unlikely that this feature will be fixed in future versions without external help, it could be relatively easy to implement it (in which case it would be a good idea to submit a patch).