Table bottom border is missing when page breaks in the middle of a XSL-FO table Options

codeling Posts: 1103 Points: 4638
Posted: Friday, September 22, 2017 2:59:38 PM

To ensure the header and bottom border is shown  in case when the page breaks in the middle of a XSLT-FO table, you export the <xsl:table-header> and  <xsl:table-footer> elements in FO file.

For example, if you render the following FO file into PDF,

<?xml version="1.0" encoding="utf-8"?>

<fo:root
  xmlns:fo="http://www.w3.org/1999/XSL/Format"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<!-- defines the layout master -->
<fo:layout-master-set>
<fo:simple-page-master master-name="first"
                       page-height="29.7cm"
                       page-width="21cm"
                       margin-top="1cm"
                       margin-bottom="2cm"
                       margin-left="2.5cm"
                       margin-right="2.5cm">
  <fo:region-body margin-top="3cm"/>
  <fo:region-before extent="3cm"/>
  <fo:region-after extent="1.5cm"/>
</fo:simple-page-master>
  </fo:layout-master-set>

  <!-- starts actual layout -->
  <fo:page-sequence master-reference="first">
    <fo:title>Sample Doc</fo:title>

  <fo:flow flow-name="xsl-region-body" font-size="x-small" font="Times New Roman">

<!-- table start -->
<fo:table table-layout="fixed" width="100%" border-collapse="collapse">
  <fo:table-column column-width="35mm"/>
  <fo:table-column column-width="100mm"/>
  <fo:table-column column-width="20mm"/>
 
  <fo:table-body> 
    <fo:table-row>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Column 1</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Columns 2</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Column 3</fo:block>
      </fo:table-cell>
    </fo:table-row>

    <fo:table-row>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Row 1</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Some text</fo:block>
      </fo:table-cell>
    </fo:table-row>

    <fo:table-row>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Row 2</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Some text</fo:block>
      </fo:table-cell>
    </fo:table-row>

    <fo:table-row>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Row 3</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Some text</fo:block>
      </fo:table-cell>
    </fo:table-row>

    <fo:table-row>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Row 4</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Some text</fo:block>
      </fo:table-cell>
    </fo:table-row>

    <fo:table-row>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Row 5</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Some text</fo:block>
      </fo:table-cell>
    </fo:table-row>
   
    <fo:table-row>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Row 6</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Some text</fo:block>
      </fo:table-cell>
    </fo:table-row>

    <fo:table-row>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Row 7</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Some text</fo:block>
      </fo:table-cell>
    </fo:table-row>
       
  </fo:table-body>
</fo:table>
<!-- table end -->
</fo:flow>
  </fo:page-sequence>
</fo:root>

You will see that the bottom border on page 1 and the top border on page 2  are missing:

 

 

 

 

codeling Posts: 1103 Points: 4638
Posted: Friday, September 22, 2017 3:06:18 PM

By adding the <xsl:table-header> and <xsl:table-footer> elements into the above file,

<?xml version="1.0" encoding="utf-8"?>

<fo:root
  xmlns:fo="http://www.w3.org/1999/XSL/Format"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<!-- defines the layout master -->
<fo:layout-master-set>
<fo:simple-page-master master-name="first"
                       page-height="29.7cm"
                       page-width="21cm"
                       margin-top="1cm"
                       margin-bottom="2cm"
                       margin-left="2.5cm"
                       margin-right="2.5cm">
  <fo:region-body margin-top="3cm"/>
  <fo:region-before extent="3cm"/>
  <fo:region-after extent="1.5cm"/>
</fo:simple-page-master>
  </fo:layout-master-set>

  <!-- starts actual layout -->
  <fo:page-sequence master-reference="first">
    <fo:title>Sample Doc</fo:title>

  <fo:flow flow-name="xsl-region-body" font-size="x-small" font="Times New Roman">

<!-- table start -->
<fo:table table-layout="fixed" width="100%" border-collapse="collapse">
  <fo:table-column column-width="35mm"/>
  <fo:table-column column-width="100mm"/>
  <fo:table-column column-width="20mm"/>

 <fo:table-header>
         <fo:table-row border-width="0.25mm" border-style="solid">
             <fo:table-cell>
                 <fo:block></fo:block>
             </fo:table-cell>
             <fo:table-cell>
                 <fo:block></fo:block>
             </fo:table-cell>
             <fo:table-cell>
                 <fo:block></fo:block>
             </fo:table-cell>
     </fo:table-row>
 </fo:table-header>
 <fo:table-footer>
     <fo:table-row border-width="0.25mm" border-style="solid">
         <fo:table-cell>
             <fo:block></fo:block>
         </fo:table-cell>
         <fo:table-cell>
             <fo:block></fo:block>
         </fo:table-cell>
         <fo:table-cell>
             <fo:block></fo:block>
         </fo:table-cell>
     </fo:table-row>
 </fo:table-footer>
 
  <fo:table-body> 
    <fo:table-row>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Column 1</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Columns 2</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Column 3</fo:block>
      </fo:table-cell>
    </fo:table-row>

    <fo:table-row>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Row 1</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Some text</fo:block>
      </fo:table-cell>
    </fo:table-row>

    <fo:table-row>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Row 2</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Some text</fo:block>
      </fo:table-cell>
    </fo:table-row>

    <fo:table-row>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Row 3</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Some text</fo:block>
      </fo:table-cell>
    </fo:table-row>

    <fo:table-row>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Row 4</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Some text</fo:block>
      </fo:table-cell>
    </fo:table-row>

    <fo:table-row>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Row 5</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Some text</fo:block>
      </fo:table-cell>
    </fo:table-row>
   
    <fo:table-row>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Row 6</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Some text</fo:block>
      </fo:table-cell>
    </fo:table-row>

    <fo:table-row>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Row 7</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
        <fo:block>text line</fo:block>
      </fo:table-cell>
      <fo:table-cell border-width="0.5mm" border-style="solid">
        <fo:block>Some text</fo:block>
      </fo:table-cell>
    </fo:table-row>
       
  </fo:table-body>
</fo:table>
<!-- table end -->
</fo:flow>
  </fo:page-sequence>
</fo:root>

You will see the the missing borders shown there:

Users browsing this topic
Guest