Hey,
I can't seem to get rid of borders when I use a PdfPTable in a PdfPTable.
All cells are set to have no border (cell.setBorder(0)) and this works if I
add the cell to a table. But when I add that table to another table it
suddenly has, even if all of the tables have their defaultcell set to have
no borders.
I'm at a loss ...
Here's part of the code I use.
public void createTextBody(String key,String titel,String suffix) throws
IOException, DocumentException {
Font titelFont = new Font(Font.TIMES_ROMAN,8,Font.BOLD);
Font main = new Font(Font.TIMES_ROMAN,6,Font.BOLD);
Font bodyFont = new Font(Font.TIMES_ROMAN,6,Font.ITALIC);
Font mainBold = new Font(Font.TIMES_ROMAN,6,Font.BOLD);
PdfPCell cell = new PdfPCell();
applyDefaultCellProps(cell);
Phrase phrase = new Phrase(new Chunk(titel,titelFont));
cell.addElement(new Paragraph(phrase));
for(int i=1; true ; i++){
String regel = "lijn"+i+"."+suffix;
String lijn = moduleItem.getITextField(regel);
if(lijn != null){
cell.addElement(new Paragraph(new Phrase(new
Chunk(lijn,main))));
}else {
break;
}
}
String body = moduleItem.getITextField("body."+suffix);
cell.addElement(new Paragraph(new Phrase(new
Chunk(body,bodyFont))));
String foot = moduleItem.getITextField("footer."+suffix);
cell.addElement(new Paragraph(new Phrase(new
Chunk(foot,mainBold))));
List<PdfPTable> list = elementen.get(key);
PdfPTable table = createNewTable();
table.addCell(cell);
list.add(table);
som+=table.getTotalHeight();
}
private PdfPTable createNewTable(){
PdfPTable table = new PdfPTable(1);
table.setTotalWidth(WIDTH);
table.setSpacingAfter(0);
table.setSpacingBefore(0);
table.setLockedWidth(true);
return table;
}
private void applyDefaultCellProps(PdfPCell cell){
cell.setBorder(PdfPCell.NO_BORDER);
cell.enableBorderSide(Rectangle.LEFT);
cell.enableBorderSide(Rectangle.RIGHT);
cell.setPadding(5);
}
--
View this message in context:
http://itext-general.2136553.n4.nabble.com/PdfPTable-in-PdfPTable-border-troubles-tp2239893p2239893.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/