To Place row bottom border in a table

Hi,


I want to place a bottom border for a row. I have used the below code the same is not working.Please suggest how this can be acheived.

Table table1 = new Table(sec);
table1.setColumnWidths("100% ");
table1.setBackgroundColor(subjectDtl);
table1.setDefaultCellBorder(new BorderInfo(BorderSide.Left | BorderSide.Right, 0.7F, black));
table1.setBorder(new BorderInfo(BorderSide.All, 0.7F));
MarginInfo margin = new MarginInfo();
margin.setTop(0.7f);
margin.setLeft(0.7f);
margin.setRight(0.7f);
margin.setBottom(0.7f);

//Set the default cell padding to the MarginInfo object
table1.setDefaultCellPadding(margin);
Row row1 = table1.getRows().add();
row1.setVerticalAlignment(VerticalAlignmentType.Center);
row1.setDefaultCellTextInfo(cellInfo1);
row1.getCells().add(“row1”);
Row row2 = table1.getRows().add();
row2.setVerticalAlignment(VerticalAlignmentType.Center);
row2.setDefaultCellTextInfo(cellInfo2);
row2.setBorder(new BorderInfo(BorderSide.Bottom, 0.7F, black));
row2.getCells().add(“row2”);

Row row3 = table1.getRows().add();
row3.setVerticalAlignment(VerticalAlignmentType.Center);
row3.setDefaultCellTextInfo(cellInfo1);
row3.setBorder(new BorderInfo(BorderSide.Top, 0.7F, black));
row3.getCells().add(“row3”);
Row row4 = table1.getRows().add();
row4.setVerticalAlignment(VerticalAlignmentType.Center);
row4.setDefaultCellTextInfo(cellInfo2);
row4.getCells().add(“row4”);

Hi Visual,

Thanks for your inquiry. Please use new DOM approach to create table using latest release of Aspose.Pdf for Java, it will help you to accomplish the task. Please check sample code snippet as following.

Document doc = **new** Document();

Page page = doc.getPages().add();

// Initializes a new instance of the Table

com.aspose.pdf.Table table = **new** com.aspose.pdf.Table();

table.setColumnWidths("150 150");

// add row to table

com.aspose.pdf.Row row1 = table.getRows().add();

// add table cells

row1.getCells().add("Column 1");

row1.getCells().add("Column 2");

row1.setBorder(**new** com.aspose.pdf.BorderInfo(com.aspose.pdf.BorderSide.*Bottom*, .5f, com.aspose.pdf.Color.*getLightGray*()));

// create a loop to add 10 rows

**for** (**int** row_count = 1; row_count < 5; row_count++)

{

// add row to table

com.aspose.pdf.Row row = table.getRows().add();

// add table cells

com.aspose.pdf.Cell cell1 = row.getCells().add();

cell1.getParagraphs().add(**new** TextFragment("test"));

com.aspose.pdf.Cell cell2 = row.getCells().add();

row.setBorder(**new** com.aspose.pdf.BorderInfo(com.aspose.pdf.BorderSide.*Bottom* , .5f, com.aspose.pdf.Color.*getLightGray* ()));

}

// Add table object to first page of input document

page.getParagraphs().add(table);

doc.save(*myDir*+"table_out.pdf");

Please feel free to contact us for any further assistance.

Best Regards,