Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XSL-FO when setting table-cell background it overwrites / overlaps table borders

I am having an issue and have not found a solution/workaround (although there are similar questions that have been posed) to the XSL-FO problem with cell background. We are using Apache FOP 0.25 and a rapid upgrade to the newer version another PDF processor is not feasible at the moment.

The thing is that when I set background-color on a cell, the new background filling covers borders of the table that are visible otherwise (0.5pt solid). I have tried a couple of ways to overcome it, but they all lead to suboptimal results:

  • setting border to 1pt - the border becomes visible but has different widths depending upon if it runs along a cell with background-color or without. It is clearly too fat.
  • setting borders on each table-cell separately that has background-color. That works but I see gaps between borders that are set on the cells without background and the ones with. In the example below there would be visible gaps between vertical borders of cell 1.1 and cell 2.1 but not between 2.1 and 3.1.

    __________________________
    |cell 1.1: background    | 
    |cell 2.1: no background |
    |cell 3.1: no background |
    --------------------------
    

Are there any practical workarounds to solve the issue? I am setting background-color on the table-cell element, that should be correct, right?

Many thanks

like image 390
d56 Avatar asked Apr 06 '11 21:04

d56


1 Answers

good example for borders and fill patterns which are work with Apache FOP

    <fo:table border="1pt solid black">
        <fo:table-body border="inherit">
          <fo:table-row border="inherit">
            <fo:table-cell border="inherit" background-color="#F2F2F2" number-rows-spanned="2">
              <fo:block>data</fo:block>
            </fo:table-cell>
            <fo:table-cell border="inherit" background-color="#D9D9D9">
              <fo:block>data2</fo:block>
            </fo:table-cell>
          </fo:table-row>
          <fo:table-row border="inherit">
            <fo:table-cell border="inherit" background-color="#C0C0C0">
              <fo:block>data3</fo:block>
            </fo:table-cell>
          </fo:table-row>
        </fo:table-body>
    </fo:table>
like image 130
Eir Nym Avatar answered Sep 28 '22 03:09

Eir Nym