An invisible border of pdfptable

佐手、 提交于 2020-01-31 04:06:47

问题


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?


回答1:


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




回答2:


In my app it works like this:

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



回答3:


The below works for me.

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



回答4:


    PdfPTable nestedTable = new PdfPTable();
    nestedTable.DefaultCell.Border = 0;

    nestedTable.AddCell(new Phrase("First");
    nestedTable.AddCell(new Phrase("Second");
    nestedTable.AddCell(new Phrase("2515");

    PdfPCell nestCell= new PdfPCell(nestedTable);



回答5:


set cell color white.

cellOne.setBorderColor(BaseColor.WHITE);



回答6:


you can hide the border like this

PdfPCell cell = new PdfPCell ();
cell.setBorder(Rectangle.NO_BORDER);


来源:https://stackoverflow.com/questions/4900514/an-invisible-border-of-pdfptable

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!