Reputation: 16525
I have a table with some cells and nested tables.
Nested tables have border around them but I don't know why.
Cells don't have borders because I add to cell and nested cell:
cell.setBorder(Rectangle.NO_BORDER);
Then I add nested table into table;
table.addCell(nestedTable());
It seems like it's the Cell around the nested table that have border.
How to do to set it to zero?
UPDATE:
public static void main(String[] args) {
Document document = new Document();
try {
PdfWriter.getInstance(document, new FileOutputStream("Table2.pdf"));
document.open();
PdfPTable table = new PdfPTable(3);
PdfPCell cell1 = new PdfPCell(new Phrase("Cell 1"));
cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
cell1.setBorder(Rectangle.NO_BORDER);
PdfPCell cell2 = new PdfPCell(new Phrase("Cell 2"));
cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
cell2.setBorder(Rectangle.NO_BORDER);
PdfPCell cell3 = new PdfPCell(new Phrase("Cell 3"));
cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
cell3.setBorder(Rectangle.NO_BORDER);
PdfPTable nestedTable = new PdfPTable(2);
PdfPCell cell4 = new PdfPCell(new Phrase("Nested Cell 1"));
cell4.setHorizontalAlignment(Element.ALIGN_CENTER);
cell4.setBorder(Rectangle.NO_BORDER);
nestedTable.addCell(cell4);
PdfPCell cell5 = new PdfPCell(new Phrase("Nested Cell 2"));
cell5.setHorizontalAlignment(Element.ALIGN_CENTER);
cell5.setBorder(Rectangle.NO_BORDER);
nestedTable.addCell(cell5);
table.addCell(cell1);
table.addCell(cell2);
table.addCell(cell3);
table.addCell(nestedTable);
table.addCell(nestedTable);
table.addCell(nestedTable);
document.add(table);
document.close();
} catch (Exception e) {
e.printStackTrace();
}
}
Upvotes: 1
Views: 2438
Reputation: 16525
ok I got it.
I cant do this:
table.addCell(nestedTable);
instead of this I need to create new cell and inside of this cell add nested table and now I have no border
Upvotes: 2
Reputation: 7512
Try modifying the default cell of your main table:
PdfPTable table = new PdfPTable(3);
table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
See the API for more information.
Upvotes: 4