【问题标题】:Invalid property value encountered in column-number fop在列号 fop 中遇到无效的属性值
【发布时间】:2015-01-23 12:42:03
【问题描述】:

我正在使用 Apache FOP 将我的文件打印为 PDF。从 FO 转换为 PDF 时出现以下错误:

column-number="5" 中遇到的属性值无效:org.apache.fop.fo.expr.PropertyException: fo:table-cell 在第 5 列中重叠。(参见位置 17071:79)

我得到了很多行和列。

在 pdf 中,表格正确显示。谁能告诉我这个错误的根本原因是什么?一般什么时候会抛出这个错误?

【问题讨论】:

    标签: pdf apache-fop


    【解决方案1】:

    fo:table-cell 中的column-number 属性的值由于与先前单元格的number-columns-spannednumber-rows-spanned 冲突而无法遵守时,将引发此异常。

    单元格跨列导致的错误

    让我们看看这个简单的例子,它显示了一个有 3 列和 1 行的表,它会产生相同类型的错误:

    <fo:table>
        <fo:table-column column-number="1"/>
        <fo:table-column column-number="2"/>
        <fo:table-column column-number="3"/>
        <fo:table-body>
            <fo:table-row>
                <fo:table-cell column-number="1">
                    <fo:block>a</fo:block>
                </fo:table-cell>
                <fo:table-cell column-number="2" number-columns-spanned="2">
                    <fo:block>b</fo:block>
                </fo:table-cell>
                <fo:table-cell column-number="3">
                    <fo:block>c</fo:block>
                </fo:table-cell>
            </fo:table-row>
        </fo:table-body>
    </fo:table>
    
    • 第一个细胞是正常细胞
    • 第二个单元格跨越两列,因此它占据了第 2 列和第 3 列
    • 但是有另一个单元格,声称在第 3 列 -> 第二个和第三个单元格在第 3 列重叠

    单元格跨行导致的错误

    如果存在跨越多行的单元格,可能会发生类似的情况,并与以下行中的单元格冲突:

    <fo:table>
        <fo:table-column column-number="1"/>
        <fo:table-column column-number="2"/>
        <fo:table-body>
            <fo:table-row>
                <fo:table-cell column-number="1" number-rows-spanned="2">
                    <fo:block>A</fo:block>
                </fo:table-cell>
                <fo:table-cell column-number="2">
                    <fo:block>B</fo:block>
                </fo:table-cell>
            </fo:table-row>
            <fo:table-row>
                <fo:table-cell column-number="1">
                    <fo:block>C</fo:block>
                </fo:table-cell>
                <fo:table-cell column-number="2">
                    <fo:block>D</fo:block>
                </fo:table-cell>
            </fo:table-row>
        </fo:table-body>
    </fo:table>
    

    这里的冲突单元格是第 1 行的第一个单元格和第 2 行的第一个单元格。

    结论

    我建议检查您的 FO 文件或创建它的代码(可能是 XSLT?)以查找具有 number-columns-spannednumber-rows-spanned 的单元格,然后(在存在冲突的情况下)删除这些属性或冲突的单元格。

    在 pdf 中,表格是正确的。

    非常奇怪,因为这个异常的严重性(至少在 FOP 1.1 中)是致命的,即程序异常终止。

    我认为,如果确实创建了一个 pdf 文件,则有可能不正确的表格已被错误完全“吞噬”,因此您的输出可能会丢失某些部分

    【讨论】:

      猜你喜欢
      • 2020-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-15
      • 2015-03-06
      • 1970-01-01
      • 2014-08-21
      • 1970-01-01
      相关资源
      最近更新 更多