List of utility methods to do Swing RTF
String | RTF2TXT(String Str) RTFTXT if (Str != null && Str.startsWith("{\\rtf1") == true) { Str = RTF_CELL_PATTERN.matcher(Str).replaceAll(". $0"); RTFEditorKit RTF = new RTFEditorKit(); Document doc = RTF.createDefaultDocument(); RTF.read(new StringReader(Str), doc, 0); Str = doc.getText(0, doc.getLength()); return Str; ... |
String | rtfToPlain(String rtf) rtf To Plain RTFEditorKit rtfParser = new RTFEditorKit(); Document document = rtfParser.createDefaultDocument(); try { rtfParser.read(new ByteArrayInputStream(rtf.getBytes()), document, 0); return document.getText(0, document.getLength()); } catch (Exception e) { throw new RuntimeException("Error converting RTF to plain text", e); |