Hello
I am using iText for RTF output on a larger project here, but I encountered
a few problems with lists and tables.
I am using iText 1.3.1
I made a few changes to the code that solved my problems so I decided to
share them.
The lists items were split in several items, so I had a look at the source,
in the write method of RtfListItem there is
for(int i = 0; i < chunks.size(); i++) {
RtfChunk rtfChunk = (RtfChunk) chunks.get(i);
rtfChunk.setSoftLineBreaks(true);
result.write(rtfChunk.write());
result.write(RtfParagraph.PARAGRAPH);
}
writing a new paragraph after each chunk is strange, moving that line after
the for loop solved my problem.
At the same place, the chunks.get(i) is casted into RtfChunk, but I want to
put Anchor objects within my lists items (which is accepted by the generic
object ListItem and works fine in PDF). So it seems better to cast as
RtfBasicElement:
for(int i = 0; i < chunks.size(); i++) {
RtfBasicElement element = (RtfBasicElement) chunks.get(i);
if(element instanceof RtfChunk){
((RtfChunk)element).setSoftLineBreaks(true);
}
result.write(element.write());
}
result.write(RtfParagraph.PARAGRAPH);
For tables, I had each lines duplicated (opening the resulting RTf with
oowriter), in RtfRow.write() there is
result.write(writeRowDefinitions());
for(int i = 0; i < this.cells.size(); i++) {
RtfCell rtfCell = (RtfCell) this.cells.get(i);
result.write(rtfCell.write());
}
result.write(DELIMITER);
result.write(writeRowDefinitions());
result.write(ROW_END);
result.write("\n".getBytes());
the definitions are written before AND after the line is written, removing
the two lines
result.write(DELIMITER);
result.write(writeRowDefinitions());
solved my problem.
I hope this help.
--
Renaud MICHEL
-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions