下面的代码不起作用。
Table table = new Table(2);
table.setBorder(Border.NO_BORDER);
Run Code Online (Sandbox Code Playgroud)
我是itext7的新手,我想要做的就是让我的桌子无边界。喜欢怎么做?
默认情况下,表格本身不负责iText7中的边框,而单元格则负责。如果要使用无边界表,则需要将每个单元格设置为无边界(或者,如果仍要在内部边界内,请将外部单元格的边缘设置为无边界)。
Cell cell = new Cell();
cell.add("contents go here");
cell.setBorder(Border.NO_BORDER);
table.addCell(cell);
Run Code Online (Sandbox Code Playgroud)
小智 6
您可以编写一个方法来运行表的所有子项并设置 NO_BORDER。
private static void RemoveBorder(Table table)
{
for (IElement iElement : table.getChildren()) {
((Cell)iElement).setBorder(Border.NO_BORDER);
}
}
Run Code Online (Sandbox Code Playgroud)
这为您提供了仍然可以使用的优势
table.add("whatever");
table.add("whatever");
RemoveBorder(table);
Run Code Online (Sandbox Code Playgroud)
而不是在所有单元格手册上更改它。
| 归档时间: |
|
| 查看次数: |
2168 次 |
| 最近记录: |