iText表格左边距

3

如何给表格设置左边距或右边距(不是单行内容)?我想要像setSpacingAfter()setSpacingBefore()那样的东西,但是是水平方向的。对于段落有setIndentationRight(),但是我找不到类似于此的表格属性。


将整个表格放在一个外部表格中,该外部表格只有一个单元格,并在该外部单元格上设置左/右内边距。 - COeDev
1
在该表中添加两列,分别为“First”和“Last”,并设置所需的大小,然后移除所有边框。就这样。 - Rajan
1个回答

2

如果您将表格放入缩进的段落中,就可以对其进行缩进。

table = new PdfPTable(2);

// Makes the table to get the 100 percent of space that is available horizontally
table.setWidthPercentage(100);

// Creates a paragraph indentated by the left by 20 units.
p = new Paragraph();

// You insert the table into the indentated paragraph.
p.add(table);

p.setIndentationLeft(20);

// And finally, this will show a table indentated to the left by 20 units.      
document.add(p);

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接