An invisible border of pdfptable

The below works for me.

table.getDefaultCell().setBorderWidth(0f);

For iText 7

Table table = new Table();
table.SetBorder(Border.NO_BORDER);

The Border Elements of the PdfPTable are defined by the PdfPCell which are added to the table. Each Cell will have its own style/formatting. Here is the API: http://api.itextpdf.com/

Example

PdfPTable table = new PdfPTable(2);
PdfPCell cellOne = new PdfPCell(new Phrase("Hello"));
PdfPCell cellTwo = new PdfPCell(new Phrase("World"));

cellOne.setBorder(Rectangle.NO_BORDER);
cellOne.setBackgroundColor(new Color(255,255,45));

cellTwo.setBorder(Rectangle.BOX);

table.addCell(cellOne);
table.addCell(cellTwo);

If you want more detail about the Rectangle/Border values, take a look at the IText Constant values section for Rectangle, here : http://api.itextpdf.com/constant-values.html


In my app it works like this:

PdfPTable table = new PdfPTable(2);
table.getDefaultCell().setBorder(0);
...

Tags:

Java

Itext