2011-12-18 66 views
0

我正在使用iText 2.1.7與春天,我想創建一個PDF文檔。 我爲了才達到像現在用一個嵌套表:嵌套的iText表不顯示邊框

 text1          text2 
------------------------------------   ---------------------------- 
| text1    text4  |  | text1      | 
| text2    text5  |  | text2      | 
| text3       |  |       | 
|         |  |       | 
-------------------------------------  ------------------------------ 

爲了做到這一點我使用的是大表內2個嵌套表,大表包含全段和嵌套表是什麼如上所述。

我的代碼:

 Table miniTable1 = new Table(2); 
     Table miniTable2 = new Table(1); 

     miniTable1.setBorder(Rectangle.BOX); 
     miniTable1.setBackgroundColor(new Color(0, 255, 0)); 
     miniTable1.setBorderWidth(5); 
     miniTable2.setBorderWidth(5); 

     //add text here as cells in the mini tables 

     Cell cell1 = new Cell(miniTable1); 

     Cell cell2 = new Cell(miniTable2); 
     cell2.setHorizontalAlignment("center"); 

     cell1.setColspan(2); 
     table.addCell(cell1); 
     cell2.setColspan(1); 
     table.addCell(cell2); 

的問題是,小表的邊框不顯示。

回答

0

將邊框放在單元格上,例如cell2.setBorderWidth(5f);