1
votes

I have an XSL-FO file that is then transformed into a PDF file using FOP 0.20.5. I have a table with header columns that are shown on every page, header and footer.

My problem with the output is the following: the text that belongs to a cell in the 5th column is split between pages (in the next page there is only the part of text that didn't somehow fit on previous page, other cells in the row are empty).
How can i prevent this behaviour? Instead of that move I would like the whole content to be placed on the next page, not just a part of that text (so of course when this happens last row shouldn't exist on previous page but the whole row is moved to next page).

current output

Parts of code from xsl file:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet exclude-result-prefixes="fo" 
version="1.1" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:java="java" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:output method="xml" 
version="1.0" 
omit-xml-declaration="no" 
indent="yes"/>

Layout-master-set part:

 <fo:layout-master-set>
                <fo:simple-page-master master-name="A4" page-height="29.7cm" page-width="21.0cm" margin-top="0.5cm" margin-bottom="0.5cm" margin-left="2.0cm" margin-right="2.0cm">
                        <fo:region-before region-name="xsl-region-before" extent="2cm"/>
                        <fo:region-body region-name="xsl-region-body" margin-top="2cm" margin-bottom="4.0cm"/>
                        <fo:region-after region-name="xsl-region-after" extent="2.5cm"/>
                    </fo:simple-page-master>
    </fo:layout-master-set>

Table part:

<fo:flow flow-name="xsl-region-body">

             <fo:table table-layout="fixed">

                        <fo:table-column column-width="{$PAR_C1SIZE}cm"/>
                         ...
                         <!-- more table-column def. -->
                         ...
                         ... 
                        <xsl:if test="string-length($PAR_MODIFY) &gt; 0">
                            <fo:table-column column-width="0.3cm"/>
                        </xsl:if>
                        <fo:table-header>
                            <fo:table-row>
                                <xsl:attribute name="background-color">#60c3d9</xsl:attribute>
                                <fo:table-cell display-align="center" border-top="0.05em solid #60c3d9" border-right="0.05em solid white">
                                    
                                    <fo:block text-align="center" color="white" font-weight="bold">Date blabla</fo:block>
                                
                                </fo:table-cell>
                                ...
                                ...
                                <!-- more cells -->
                                ...
                                ...
                                ...
                            </fo:table-row>
                        </fo:table-header>
                        <fo:table-body>
                            <xsl:apply-templates select="POS"/>
                        </fo:table-body>
                    </fo:table>
</fo:flow>

Row part:

<xsl:template match="POS">
        <xsl:apply-templates select="SP"></xsl:apply-templates>
</xsl:template>


<xsl:template match="SP">
        <fo:table-row >

            <fo:table-cell display-align="center" border="0.05em solid grey" >
                <fo:block text-align="center">
                    <xsl:value-of select="'Bla bla bla'"/>
                </fo:block>

            </fo:table-cell>
            

            <fo:table-cell display-align="center" border="0.05em solid grey">
                <fo:block text-align="center">
                        <xsl:value-of select="'Bla bla bla 2222..'"/>
                </fo:block>
            </fo:table-cell>
            
            ...
            ...
            ...
            <!-- more table-cells -->
            ...
            ...
            ...
            ...
        </fo:table-row>
</xsl:template>

What is causing this behaviour and how can i fix it ?

1
In CSS tr { page-break-inside : avoid } might help, I think for XSL-FO there are similar attributes or properties you can set for a table/table-row.Martin Honnen
Test whether e.g. <fo:table-row page-break-inside="avoid"> applied on your table row elements fixes the issue: w3.org/TR/xsl11/#d0e26492Martin Honnen
Sry i'm using fop-0.20.5.jar for converting xsl to pdf. Adding that to table row unfortunately didn't help @MartinHonnen.slodeveloper
O.something seems like way too old, 2.5 is the current release, I thinkMartin Honnen

1 Answers

1
votes

As @MartinHonnen said, FOP 0.20.5 is very old. You could try keep-together.within-page="always" (see https://www.w3.org/TR/xsl11/#keep-together) on either or both of the fo:table-row and fo:table-cell. I have a vague memory of early FOP versions implementing that before FOP supported much else about keeps.

You could also try setting a large value for orphans and/or widows to see if that will stop your paragraph from breaking.