public class TableAlignment
Example:
Document doc = new Document(getMyDir() + "Tables.docx");
Table table = (Table) doc.getChild(NodeType.TABLE, 0, true);
// Align the table to the center of the page
table.setAlignment(TableAlignment.CENTER);
// Clear any existing borders and shading from the table
table.clearBorders();
table.clearShading();
// Set a green border around the table but not inside
table.setBorder(BorderType.LEFT, LineStyle.SINGLE, 1.5, Color.GREEN, true);
table.setBorder(BorderType.RIGHT, LineStyle.SINGLE, 1.5, Color.GREEN, true);
table.setBorder(BorderType.TOP, LineStyle.SINGLE, 1.5, Color.GREEN, true);
table.setBorder(BorderType.BOTTOM, LineStyle.SINGLE, 1.5, Color.GREEN, true);
// Fill the cells with a light green solid color
table.setShading(TextureIndex.TEXTURE_SOLID, Color.GREEN, Color.GREEN);
doc.save(getArtifactsDir() + "Table.SetOutlineBorders.docx");
Field Summary | ||
---|---|---|
static final int | LEFT | |
The table is aligned to the left.
|
||
static final int | CENTER | |
The table is centered.
|
||
static final int | RIGHT | |
The table is aligned to the right.
|