Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An invisible border of pdfptable

Tags:

java

itext

I am using iText library for generating pdf files in Java. I am writing data in pdfptable , how can I make the borders of table invisible?

like image 379
yogsma Avatar asked Feb 04 '11 16:02

yogsma


People also ask

How to remove table border in itext java?

Hence: if you want to remove the borders of the table, you need to remove the borders of each cell. cell. setBorder(Rectangle. NO_BORDER);


2 Answers

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

like image 75
Sean Avatar answered Oct 10 '22 22:10

Sean


In my app it works like this:

PdfPTable table = new PdfPTable(2); table.getDefaultCell().setBorder(0); ... 
like image 27
Sura Chaitanya Avatar answered Oct 11 '22 00:10

Sura Chaitanya