如何给表格设置左边距或右边距(不是单行内容)?我想要像setSpacingAfter()
和setSpacingBefore()
那样的东西,但是是水平方向的。对于段落有setIndentationRight()
,但是我找不到类似于此的表格属性。
如果您将表格放入缩进的段落中,就可以对其进行缩进。
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);