2
votes

I'm generating some PDF with Apache FOP and I would like to have some dotted borders on some cells. However, it seems that the border background takes its color from the Table itself and not the cell, which is rather odd IMHO.

This is a simple example :

    <?xml version="1.0" encoding="UTF-8" ?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xml:lang="en">
    <fo:layout-master-set>
        <fo:simple-page-master master-name="A4-landscape" page-height="210mm" page-width="297mm">
            <fo:region-body margin-top="15mm" margin-bottom="15mm" margin-left="15mm" margin-right="15mm" />
            <fo:region-before region-name="docHeader"/>
            <fo:region-after region-name="docFooter" extent="15mm" />
        </fo:simple-page-master>
    </fo:layout-master-set>
    <fo:page-sequence master-reference="A4-landscape" initial-page-number="1">
        <fo:flow flow-name="xsl-region-body">
            <fo:block>
                <fo:table table-layout="fixed" break-after="page" background-color="red">
                    <fo:table-column column-width="100.0mm" />
                    <fo:table-body>
                        <fo:table-row height="25.0mm">
                            <fo:table-cell text-align="center" display-align="center" background-color="blue" border-top="0.35277778mm dotted green" 
                                           border-bottom="0.35277778mm solid rgb(0,0,0)"
                                           border-left="0.35277778mm solid rgb(0,0,0)" 
                                           border-right="0.35277778mm solid rgb(0,0,0)">
                                <fo:block-container overflow="hidden">
                                    <fo:block wrap-option="no-wrap">test</fo:block>
                                </fo:block-container>
                            </fo:table-cell>
                        </fo:table-row>
                    </fo:table-body>
                </fo:table>
            </fo:block>
            <fo:block id="endOfDoc"></fo:block>
        </fo:flow>
    </fo:page-sequence>
</fo:root>

And this is the result :

The border background is red and not blue.

Do you have any ideas how to set the border's background color? Id this a normal behaviour?

1

1 Answers

4
votes

Yes, this is normal behavior. The cell is drawn inside the border and the dotted border is split between. Using RenderX XEP with miters corners and this becomes a little more obvious in what happens. Look at this zoomed image of the corner:

enter image description here

Now, you could try to juggle around what you are doing as one option. Like this:

         <fo:table table-layout="fixed" break-after="page" background-color="red">
                <fo:table-column column-width="100.0mm" />
                <fo:table-body>
                    <fo:table-row>
                        <fo:table-cell background-color="blue" display-align="center" 
                            border-bottom="0.35277778mm solid rgb(0,0,0)"
                            border-left="0.35277778mm solid rgb(0,0,0)" 
                            border-right="0.35277778mm solid rgb(0,0,0)">
                            <fo:block-container  height="25.0mm" overflow="hidden" border-top="0.35277778mm dotted green" text-align="center" >
                                <fo:block wrap-option="no-wrap">test</fo:block>
                            </fo:block-container>
                        </fo:table-cell>
                    </fo:table-row>
                </fo:table-body>
            </fo:table>

and you would get this:

enter image description here