This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am working on a requirement of generating a RTF document using iText API. When i am using iText1.4.8 jar file there is no exception and RTF file is successfully generated.
But I got the following below exception when I am using iText 2.1.3 and iText-rtf-2.1.7 jar files.(because after iText-1.4.8.jar version, support of rtf is moved.) Exception in thread "main" java.lang.NoSuchMethodError:
at com.lowagie.text.rtf.text.RtfParagraph.<init>(Unknown Source)
at com.lowagie.text.rtf.RtfMapper.mapElement(Unknown Source)
at com.lowagie.text.rtf.RtfWriter2.add(Unknown Source)
at com.lowagie.text.Document.add(Unknown Source)
I observed that RTF file is getting generated but with no content.
No, iText 2 still has support for RTF (as evidenced by the fact that the com.lowagie.text.rtf.text.RtfParagraph class still exists). That method was likely made obsolete and removed at some point.
Note that the release history (http://itextpdf.com/history.php) mentions big changes in RTF handling between iText 2.0 and iText 2.1. So you could try using iText 2.0.8 instead of 2.1.7 to see if that makes a difference.
Note: You should UseCodeTags when posting code of any length. It's unnecessarily hard to read the code as it is, making it less likely that people will bother to do so. Also be sure to post any import statements - if those are missing, people are very unlikely to try and run that code for themselves.
Ulf Dittmer wrote:That method was likely made obsolete and removed at some point.
I think it's the other way around. iText-rtf-2.1.7 is throwing the exception because it's missing the method in iText-2.1.4.
Srikanth, iText-2.1.7 is available as well. The two probably work best if they have the same version. Does the error disappear when you upgrade iText to 2.1.7? See http://sourceforge.net/projects/itext/files/ for all files, then check the 2.1.7 branch.