Hi,

I'm running into a problem with nested tables in iText and am hoping someone has a solution.
 
I have a 2 column table with a table nested in both cells (0,0) and cells (1,0)     (where I am listing column#s first).  That works fine.  However I want to do a cellspan on cells (0,1) and (1,1), but am unable.  Althought iText "spans" the cells (in that it only requires 1 cell to fill the row), the actual text within that cell is limited to the width of cell(0,1) and not of cell(0,1) + cell(1,1) as expected.
 
Any additional insight and/or help would be greatly appreicated!
 
 
Below is the sample code I used to create the table.
  
Table table = new Table(2);
table.setWidth(100);
table.setBorderWidth(1);
table.setBorderColor(java.awt.Color.BLACK);
table.setPadding(0);
table.setSpacing(1);
 
Table col1 = new Table(2);
col1.setWidth(100);
col1.setBorderWidth(1);
col1.setBorderColor(java.awt.Color.BLACK);
col1.setPadding(0);
col1.setSpacing(1);
 
for( int i = 0; i < 6; i++ )
{
 Cell cellcol1 = new Cell();
 cellcol1.addElement( new Phrase( "this is col1 cell # " + i, getCurrentFont(request) ) );
 col1.addCell( cellcol1 );
}
 
Cell cell = new Cell();
cell.addElement( col1 );
table.addCell ( cell );
 
Table col2 = new Table(2);
col2.setWidth(100);
col2.setBorderWidth(1);
col2.setBorderColor(java.awt.Color.BLACK);
col2.setPadding(0);
col2.setSpacing(1);
 
for( int i = 0; i < 6; i++ )
{
 Cell cellcol2 = new Cell();
 cellcol2.addElement( new Phrase( "this is Table col2 cell # " + i, getCurrentFont(request) ) );
 col2.addCell( cellcol2 );
}
cell = new Cell();
cell.addElement( col2 );
table.addCell( cell );
 
for( int i = 0; i < 5; i++ )
{
 cell = new Cell();
 cell.setColspan(2);
 cell.addElement( new Phrase("this is the main table entry #" + i, getCurrentFont(request) ) );
 table.addCell( cell );
}
document.add(table);
 
 
Thanks,
 
Eric
 

Reply via email to