Apache FOP 上的虚线边框背景

Dotted border background on Apache FOP

我正在使用 Apache FOP 生成一些 PDF,我希望在某些单元格上有一些虚线边框。但是,边框背景的颜色似乎来自 Table 本身而不是单元格,恕我直言,这很奇怪。

这是一个简单的例子:

    <?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>

这是结果:

您知道如何设置边框的背景颜色吗? 这是正常行为吗?

是的,这是正常行为。单元格被绘制在边框内,虚线边框被分隔开。使用带斜角的 RenderX XEP,这在发生的情况中变得更加明显。看看这个角落的放大图像:

现在,您可以尝试兼顾您正在做的事情作为一种选择。像这样:

         <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>

你会得到这个: