Reputation: 631
How is it possible to set a left margin or right margin to a table (not to content in single row)? I want something like setSpacingAfter()
and setSpacingBefore()
but horizontally. There is setIndentationRight()
for Paragraph but I can not find something like that for a table.
Upvotes: 3
Views: 7911
Reputation: 900
You can indent a table if you put it into an indentated paragraph.
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);
Upvotes: 2