Search in sources :

Example 6 with RTFEditorKit

use of javax.swing.text.rtf.RTFEditorKit in project openj9 by eclipse.

the class RtfChild method convert.

public static String convert(String rtf) throws Exception {
    DefaultStyledDocument styledDoc = new DefaultStyledDocument();
    RTFEditorKit rtfKit = new RTFEditorKit();
    StringReader reader = null;
    reader = new StringReader(rtf);
    rtfKit.read(reader, styledDoc, 0);
    Document doc = styledDoc.getDefaultRootElement().getDocument();
    String txt = doc.getText(0, doc.getLength());
    return txt;
}
Also used : StringReader(java.io.StringReader) RTFEditorKit(javax.swing.text.rtf.RTFEditorKit) DefaultStyledDocument(javax.swing.text.DefaultStyledDocument) Document(javax.swing.text.Document) DefaultStyledDocument(javax.swing.text.DefaultStyledDocument)

Example 7 with RTFEditorKit

use of javax.swing.text.rtf.RTFEditorKit in project openj9 by eclipse.

the class Rtf method convert.

public static String convert(String rtf) throws Exception {
    DefaultStyledDocument styledDoc = new DefaultStyledDocument();
    RTFEditorKit rtfKit = new RTFEditorKit();
    StringReader reader = null;
    reader = new StringReader(rtf);
    rtfKit.read(reader, styledDoc, 0);
    Document doc = styledDoc.getDefaultRootElement().getDocument();
    String txt = doc.getText(0, doc.getLength());
    return txt;
}
Also used : StringReader(java.io.StringReader) RTFEditorKit(javax.swing.text.rtf.RTFEditorKit) DefaultStyledDocument(javax.swing.text.DefaultStyledDocument) Document(javax.swing.text.Document) DefaultStyledDocument(javax.swing.text.DefaultStyledDocument)

Aggregations

RTFEditorKit (javax.swing.text.rtf.RTFEditorKit)7 Document (javax.swing.text.Document)6 StringReader (java.io.StringReader)5 DefaultStyledDocument (javax.swing.text.DefaultStyledDocument)5 ByteArrayInputStream (java.io.ByteArrayInputStream)2 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 Dragboard (javafx.scene.input.Dragboard)1 BadLocationException (javax.swing.text.BadLocationException)1 HTMLEditorKit (javax.swing.text.html.HTMLEditorKit)1