Hi ,
I would like to achieve a specific table structure, The structure is as follows.
There are 3 tables say A, B and C
Table A - 2 rows 2 columns
1st cell has colspan of 2 and rest have 1 colspan.
Table A has 100 100 column width respectively
Table B - 1 row 1 column
colspan is 1
Table B has 100 column width
and Table C - 1 row and 2 columns
the 1st column conatins table A and 2nd contains table B
I used following code to achieve this
private static Table getTable() {
Table table1 = new Table();
table1.setColumnWidths( “100 100” );
Row row = table1.getRows().add();
Cell cell = row.getCells().add();
cell.getParagraphs().add( new TextFragment( “1” ) );
cell.setColSpan( 2 );
row = table1.getRows().add();
cell = row.getCells().add();
cell.getParagraphs().add( new TextFragment( “2” ) );
cell.setColSpan( 1 );
cell = row.getCells().add();
cell.getParagraphs().add( new TextFragment( “3” ) );
cell.setColSpan( 1 );
Table table2 = new Table();
table2.setColumnWidths( “100” );
row = table2.getRows().add();
cell = row.getCells().add();
cell.getParagraphs().add( new TextFragment( “4” ) );
Table table = new Table();
//table.setColumnWidths( “200 100” );
row = table.getRows().add();
cell = row.getCells().add();
cell.getParagraphs().add( table1 );
cell = row.getCells().add();
cell.getParagraphs().add( table2 );
return table;
}
This code insert cell with content 4 above cell with content 3.
Which is not expected.
NOTE - if I uncomment this line from Table C - table.setColumnWidths( “200 100” );
Then the desired behaviour is achieved but in actual scenarios I wont be able to calculate table widths of the childs differently. So please provide a solution with that line commented. If I am doing something wrong please correct me.
I am using Aspose 11 with com.aspose.pdf classes