Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How To Read RTF file in JAVA? Using iText?

870192Jul 6 2011 — edited Jul 7 2011
How To Read RTF file in JAVA? Using iText?.....

import java.io.*;

import com.lowagie.text.*;
import com.lowagie.text.rtf.*;

public class RTF3 {
public static void main(String[] args) {

// System.out.println("This example generate a RTF file name Sample.rtf");

// Create Document object
Document myDoc = new Document();

try {

// Create writer to listen document object
// and directs RTF Stream to the file Sample.rtf
RtfWriter2.getInstance(myDoc, new FileOutputStream("Sample.rtf"));

// open the document object
myDoc.open();

// Create a paragraph
Paragraph p = new Paragraph();
p.add("Helloworld in Rtf file..amazing isn't");

// Add the paragraph to document object
myDoc.add(p);

}
catch(Exception e) {
System.out.println(e);
}
//close the document
myDoc.close();
}
}
Exception in thread "main" java.lang.NoSuchMethodError: com.lowagie.text.Rectangle.width()F
at com.lowagie.text.rtf.document.RtfPageSetting.rectEquals(RtfPageSetting.java:433)
at com.lowagie.text.rtf.document.RtfPageSetting.guessFormat(RtfPageSetting.java:362)
at com.lowagie.text.rtf.document.RtfPageSetting.setPageSize(RtfPageSetting.java:341)
at com.lowagie.text.rtf.RtfWriter2.setPageSize(RtfWriter2.java:248)
at com.lowagie.text.Document.open(Unknown Source)
at view.RTF3.main(RTF3.java:23)

CAN you HELP me?
This post has been answered by dvohra21 on Jul 7 2011
Jump to Answer

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Aug 4 2011
Added on Jul 6 2011
3 comments
11,486 views