File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes I/O and Streams and the fly likes error while using Rtfwriter by iText version 2.1.3 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "error while using Rtfwriter by iText version 2.1.3" Watch "error while using Rtfwriter by iText version 2.1.3" New topic

error while using Rtfwriter by iText version 2.1.3

srikanth Thandra
Ranch Hand

Joined: Mar 04, 2009
Posts: 42
hello all,

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)
at RTFHelloWorld.main(

I observed that RTF file is getting generated but with no content.

Can any body help me resolving the above issue?

the sample code is below

public class RTFHelloWorld {

static String outFile = "RtfHelloWorld1.rtf";
static String resultsPath = "results/rtf/intro/";
static String resourcePath = "resources/rtf/intro/";

* @param args
public static void main(String[] args) {
// create a document
Document document = new Document();

try {
// create a RTF Writer
RtfWriter2.getInstance(document, new FileOutputStream(resultsPath +outFile));

// Open the document for processing;

// add some text
document.add(new Paragraph("Hello World")); // the error is coming at this point when i am adding paragraph element to document.

} catch (FileNotFoundException e) {
} catch (DocumentException e) {

// close the document


Thanx in advance,
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
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 ( 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.
Rob Spoor

Joined: Oct 27, 2005
Posts: 20275

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 for all files, then check the 2.1.7 branch.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: error while using Rtfwriter by iText version 2.1.3
It's not a secret anymore!