0
votes

I render a table using Apache™ FOP (Formatting Objects Processor). I want to display a yellow block with fixed height and width. Block bottom should be at the same position where row bottom is. Block should overflow cells, block should not make cell larger. I'd rather not use rowspan. Any idea how I can make block overflow cell in FOP?

Image with actual and expected output:

output

Approach 1: I tried already to rowspan=2. Table looks like expected. But the code is too complex. It requires extra logic to calculate which rows I need to span.

Approach 2:

<fo:table-row>
<fo:table-cell><fo:block>item4</fo:block></fo:table-cell>
<fo:table-cell display-align="after">
    <fo:block-container overflow="visible">
        <fo:block background-color="yellow" padding-top="1.5mm" padding-bottom="1.5mm">
            Thanks
        </fo:block>
    </fo:block-container>
</fo:table-cell>

I was hoping overflow="visible" will do the trick, but it did not.

1
It would be better if you add some details on what you've triedYMomb

1 Answers

0
votes

(preventive disclosure: I'm a FOP developer, albeit not very active nowadays)

I think your approach #1 (i.e. using number-rows-spanned) is the correct one, as it provides the most portable solution across different formatters.

Anyway, if you want to go with a "simpler" trick you could use a negative space-before in the special yellow blocks:

<fo:table width="100%" table-layout="fixed">
    <fo:table-column column-width="50%"/>
    <fo:table-column column-width="50%"/>
    <fo:table-body>
        <fo:table-row>
            <fo:table-cell border="1pt solid #000000"><fo:block>orange 1</fo:block></fo:table-cell>
            <fo:table-cell border="1pt solid #000000"><fo:block></fo:block></fo:table-cell>
        </fo:table-row>
        <fo:table-row>
            <fo:table-cell border="1pt solid #000000"><fo:block>orange 2</fo:block></fo:table-cell>
            <fo:table-cell border="1pt solid #000000"><fo:block></fo:block></fo:table-cell>
        </fo:table-row>
        <fo:table-row>
            <fo:table-cell border="1pt solid #000000"><fo:block>orange 3</fo:block></fo:table-cell>
            <fo:table-cell border="1pt solid #000000">
                <fo:block space-before="-12.8pt" space-before.conditionality="retain" background-color="yellow" padding-top="4pt" padding-bottom="4pt" font-size="16pt">Thanks</fo:block>
            </fo:table-cell>
        </fo:table-row>
    </fo:table-body>
</fo:table>
  • the negative space-before must be the difference between the height of a normal block and the height of the special one (it's easier if all lengths are expressed in points, as I did in the example): in this case (12 * 1.2) - (16 * 1.2 + 4 + 4) = -12.8
  • space-before.conditionality="retain" is needed to avoid the space to be discarded (as it is at the beginning of a cell)
  • this dirty trick only works correctly if both the normal and the special blocks produce a single line of text
  • tested with FOP 1.1 and FOP trunk

In conclusion you may be able to avoid using row-spanning cells, but it is not going to be much simpler, and it is surely a less general solution.