Set Border Style, Margins and Padding of Table
Working with Borders, Margins and Padding
Please note that it also supports the feature to set border style, margins and cell padding for tables. Before going into more technical details, it’s important to understand the concepts of border, margins and padding which are presented below in a diagram:
Borders, margins and padding
In the above figure, you can see that the borders of table, row and cell overlap. Using Aspose.PDF, a table can have margins and cells can have paddings. To set cell margins, we have to set cell padding.
To set the borders of Table, Row and Cell objects, use the Table.setBorder(), Row.setBorder() and Cell.setBorder() methods. Cell borders can also be set using the Table class’ setDefaultCellBorder() method. All border related methods above are assigned an instance of the BorderInfo class, which is created by calling its constructor. The BorderInfo constructor has many overloads that take almost all parameters required to customize the border.
Margins Or Padding
Cell padding can be managed using the Table class’ setDefaultCellBorder() method. All padding related properties are assigned an instance of the MarginInfo class that takes information about the Left, Right, Top and Bottom parameters for creating customized margins.
In the example below, the cell border width is set to 0.1 point, the table border width is set to 1 point and cell padding is set to 5 points.