【问题标题】:iText7 508 Table SummaryiText7 508 表汇总
【发布时间】:2018-07-13 15:22:41
【问题描述】:

我们正在使用 iText 7 创建一个大表格,我们几乎完全收到了 508 个投诉,但是我们缺少表格摘要规则。

有没有办法在创建时使用 iText 7 添加表格摘要?

我附上了一张我正在寻找的图片。

【问题讨论】:

    标签: itext7 section508


    【解决方案1】:

    可以将 AccessibilityProperties 添加到 Table 对象本身。 Summary 需要通过 PdfDictionary 来添加

    PdfDictionary attr = new PdfDictionary();
    attr.put(new PdfName("Summary"), new PdfString("Info about the table"));
    table.getAccessibilityProperties().addAttributes(new PdfStructureAttributes(attr));
    

    ApiDocs 可以找到here

    【讨论】:

    • 不幸的是,这并没有设置与替代文本不同的表格摘要。我试过 setAlternateDescription 和 setActualText 都没有设置表格摘要。我发现创建表格摘要的唯一方法是在 adobe 中发布 pdf 创建,这不能完全满足我们客户的需求。
    • @Ekalbs 我用正确的属性更新了答案
    • 遗憾的是这也没有做到。我不得不调整代码,因为 addAttribute 没有使用字典。 PdfDictionary attr = new PdfDictionary(); attr.put(new PdfName("Summary"), new PdfString("Summary text")); datatable.getAccessibilityProperties().addAttributes(new PdfStructureAttributes(attr));这是结果。看起来它“打破”了桌子。我必须重新标记为表格,然后我可以设置摘要(在 adobe 中)。
    • 感谢您的评论@Ekalbs 我已经尝试过您的代码,它对我有用(iText 7.1.2)。我改编了罗斯弗兰克的回答,因为不是每个人都读过 cmets。
    【解决方案2】:

    我尝试了上面的解决方案,但不幸的是 Adob​​e 的摘要可访问性检查失败。

    根据规范,可访问性属性的结构应该有点不同。应该使用下一行:

    tblContact.getAccessibilityProperties().addAttributes(new PdfStructureAttributes("Table").addTextAttribute("Summary","Table summary text" ));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-07
      • 2019-06-01
      • 1970-01-01
      • 2019-11-23
      • 2018-02-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多