Hi,
I am using Aspose 11.0.0 PDF java version.
I am using the following code to generate a table.
private static Table getDataTable() {
Table table = new Table();
// header row 1
Row row = table.getRows().add();
Cell cell = getCell(-1,-1);
cell.setRowSpan( 2 );
cell.setBackgroundColor( Color.getAqua() );
row.getCells().add(cell);
for( int j = 0; j < 4; j++ ){
cell = getCell(-1,-1);
cell.setBackgroundColor( Color.getAqua() );
row.getCells().add(cell);
}
// header row 2
row = table.getRows().add();
for( int j = 0; j < 4; j++ ){
cell = getCell(-1,-1);
cell.setBackgroundColor( Color.getAqua() );
row.getCells().add(cell);
}
for( int i = 0; i < 1000; i++ ) {
row = table.getRows().add();
for( int j = 0; j < 5; j++ ){
cell = getCell( i, j );
row.getCells().add(cell);
}
}
table.setColumnWidths( "200 200 200 200 200 " );
table.setRepeatingRowsCount( 2 );
return table;
}
private static Cell getCell( int i, int j ) {
TextSegment segment = new TextSegment( "row “+i+” cell "+j );
//TextSegment segment = new TextSegment( “This is some sample text” );
TextState state = segment.getTextState();
state.setFont( FontRepository.findFont(“Verdana”) );
state.setForegroundColor( Color.getGreen() );
state.setBackgroundColor( Color.getWheat() );
state.setFontSize( 15f );
TextFragment textFragment = new TextFragment();
textFragment.getSegments().add( segment );
Cell cell = new Cell();
cell.getParagraphs().add( textFragment );
BorderInfo info = new BorderInfo();
GraphInfo ginfo = new GraphInfo();
ginfo.setLineWidth( 2 );
ginfo.setColor( Color.getBlack() );
info.setTop( ginfo );
info.setLeft( ginfo );
info.setRight( ginfo );
info.setBottom( ginfo );
cell.setBorder( info );
MarginInfo mInfo = new MarginInfo( 5, 5, 5, 5 );
cell.setMargin( mInfo );
return cell;
}
The table has 2 row as header row that should be repeated with its styles.
The first cell has a row span of 2.
The header row text styles are maintained on the first page but the they disappear for the rest of the pages.
The image ( header row styles first page.png ) shows the styles on first page.
The image ( header row styles rest pages.png ) shows the styles on the rest of the pages
How do I maintain these styles ?
The first cell in header row which had row span the cell in not properly plotted in the final PDF( check any image attached.).
How do I also achieve this ?