Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java iText表格左边距_Java_Itext - Fatal编程技术网

Java iText表格左边距

Java iText表格左边距,java,itext,Java,Itext,如何为表格设置左边距或右边距(不设置单行内容)?我想要类似于setpacingafter()和setpacingbefore()的东西,但要水平放置。段落有setIndentationRight(),但我找不到类似于表格的内容。如果将表格放入缩进段落中,则可以缩进表格 table = new PdfPTable(2); // Makes the table to get the 100 percent of space that is available horizontally table.

如何为表格设置左边距或右边距(不设置单行内容)?我想要类似于
setpacingafter()
setpacingbefore()
的东西,但要水平放置。段落有
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);

将整个表格放在一个带有单个单元格的外部表格中,并在该外部单元格上设置左/右填充?首先在该表格中增加两列,最后按所需大小增加两列,并删除所有边框。就这样。