Eu estou usando RTFEditorKit e HTMLEditorKit para converter rtf to html pra usar no FCKeditor, quando eu converto de rtf pra html tudo certo aparentemente, olho o arquivo html e vejo a mesma coisa que no rtf. Mas quando converto de html para rtf ele perde as quebras de linha e os paragrafos, a fonte, cor, tamanho funciona.
Então quem ai pode me ajudar?
Rtf2html file
public static String convertFileStringRTF2HTML(String pathFileSource) {
StringWriter writer = new StringWriter();
try {
File file = new File(pathFileSource);
FileInputStream fi = new FileInputStream(file);
RTFEditorKit rtfEditorKit = new RTFEditorKit();
HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
Document doc = rtfEditorKit.createDefaultDocument();
rtfEditorKit.read(fi, doc, 0);
htmlEditorKit.write(writer, doc, 0, doc.getLength());
fi.close();
} catch (Exception ex) {
Logger.getLogger(Rtf2Html.class.getName()).log(Level.SEVERE, null, ex);
}
return writer.toString();
html2rtf file
public static void convertStringToFileHTML2RTF(String text, String destino) {
StringReader reader = new StringReader(text);
StringWriter writer = new StringWriter();
RTFEditorKit rtfEditorKit = new RTFEditorKit();
HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
Document html = htmlEditorKit.createDefaultDocument();
try {
htmlEditorKit.read(reader, html, 0);
FileOutputStream fo = new FileOutputStream(destino);
rtfEditorKit.write(fo, html, 0, html.getLength());
System.out.println(“criou o arquivo supostamente”);
fo.close();