Apache FOP - Table top and bottom borders missing pagebreak inside table

Posted by Thomas on Stack Overflow See other posts from Stack Overflow or by Thomas
Published on 2012-11-22T04:56:39Z Indexed on 2012/11/22 4:59 UTC
Read the original article Hit count: 571

Filed under:

I am using Apache FOP to generate a PDF from a XLS FO document.

I have created a test XLS FO document that contains a table with collapsed borders that with several tall rows. One of the rows starts on one page and ends on the next and this works as expected.

The problem is that the bottom border of the table on the first page is missing and the top border of the table on the second pages is also missing.

Below is the sample XLS FO document.

<?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>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</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>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</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>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</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>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</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>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</fo:block>
        <fo:block>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</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>

This Image shows the bottom border on page 1 missing and the top border on page 2 missing, but all text seams to be there: Borders missing

Please note that I have allready experimented with using an empty header and footer with borders, for example.

This works, but I need to use these functions for other things than fixing this issue so what I need to know is if there is an other sollution to the problem?

© Stack Overflow or respective owner

Related posts about apache-fop