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:
com.lowagie.text.Paragraph.getSpacingBefore()F
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(RTFHelloWorld.java:41)
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
document.open();
// 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) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
}
// close the document
document.close();
}
}