Hi,

It appears that when I create a list item with more than 1 chunk, a newline is generated between the chunks. when I add it to a Table. If I add the same ListItem directly to a document, it displays fine. Is there anything I can do to fix the table cell formatting? I attached the output.

Thanks
-Rich

Here's the code snippet:
List list = new List( false, 10 );
ListItem li1 = new ListItem();
ListItem li2 = new ListItem();
ListItem li3 = new ListItem();
li1.add( new Chunk( "Now is the time ",
FontFactory.getFont( FontFactory.HELVETICA, 12, Font.NORMAL ) ) );
li1.add( new Chunk( "for all ",
FontFactory.getFont( FontFactory.HELVETICA, 12, Font.NORMAL ) ) );
li1.add( new Chunk( "good",
FontFactory.getFont( FontFactory.HELVETICA, 12, Font.BOLD ) ) );
li1.add( new Chunk( " men ",
FontFactory.getFont( FontFactory.HELVETICA, 12, Font.NORMAL ) ) );
li2.add( new Chunk( "Nuber two." ) );
Anchor anchor = new Anchor( "" );
anchor.setReference( "http://www.hbs.edu"; );
anchor.add( new Chunk( "click here",
FontFactory.getFont( FontFactory.HELVETICA, 12, Font.UNDERLINE ) ) );
li3.add( new Chunk( "An Anchor - " ) );
li3.add( anchor );
li3.add( new Chunk( " or not" ) );
list.add( li1 );
list.add( li2 );
list.add( li3 );
document.add( list );
Table datatable = new Table( 1 );
int headerwidths[] = {100};
datatable.setBorderWidth( 1 );
datatable.setSpacing( 0 );
datatable.setPadding( 2 );
datatable.setOffset( 10 );
datatable.setWidths( headerwidths );
datatable.setWidth( 100 );
datatable.setBackgroundColor( new Color( 255, 255, 255 ) );
datatable.setDefaultRowspan( 1 );
Cell c = new Cell();
c.addElement( list );
datatable.addCell( c );
document.add( datatable );


Attachment: ParserDriver-2.pdf
Description: Adobe PDF document

Reply via email to