如何在itext 7 表的列之间实现space?

How to achieve space between columns in itext 7 tables?

我需要实现一个 table 看起来像图片中的那个,在列之间有 space。我试过了:

    cell.setPaddingLeft(10);
    cell.setMarginLeft(10);
    extractionMediaTable.setVerticalBorderSpacing(10);

但是 none 这些似乎影响了 table。有什么建议吗?

这应该有帮助:

    table.setBorderCollapse(BorderCollapsePropertyValue.SEPARATE);
    table.setVerticalBorderSpacing(10);
    table.setHorizontalBorderSpacing(10);

一些解释: 默认情况下,iText 创建带有折叠边框的表格,因此第一行会覆盖它。 边框分离后,可以设置它们之间的间距(水平或垂直)。

例如,查看下面的代码片段和生成的 pdf 的屏幕截图:

    Table table = new Table(3);
    table.setBorderCollapse(BorderCollapsePropertyValue.SEPARATE);
    table.setVerticalBorderSpacing(10);
    table.setHorizontalBorderSpacing(10);

    for (int j = 0; j < 10; j++) {
        for (int i = 0; i < 3; i++) {
            table.addCell(new Cell().add(new Paragraph("Cell row " + j + "col " + i )));
        }
    }