Document doc = new Document(_dataDir + "input.pdf");
// Initializes a new instance of the Table
Table table = new Table();
// Set the table border color as LightGray
table.setBorder(new BorderInfo(BorderSide.All, .5f, Color.getLightGray()));
// set the border for table cells
table.setDefaultCellBorder(new BorderInfo(BorderSide.All, .5f, Color.getLightGray()));
// create a loop to add 10 rows
for (int row_count = 1; row_count < 10; row_count++) {
// add row to table
Row row = table.getRows().add();
// add table cells
row.getCells().add("Column (" + row_count + ", 1)");
row.getCells().add("Column (" + row_count + ", 2)");
row.getCells().add("Column (" + row_count + ", 3)");
}
// Add table object to first page of input document
doc.getPages().get_Item(1).getParagraphs().add(table);
// Save updated document containing table object
doc.save(_dataDir + "document_with_table.pdf");