You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class RTF2HTMLConverterJEditorPane implements RTF2HTMLConverter {
public static final RTF2HTMLConverter INSTANCE = new RTF2HTMLConverterJEditorPane();
private RTF2HTMLConverterJEditorPane() {}
@NotNull
public String rtf2html(@NotNull final String rtf) {
final JEditorPane p = new JEditorPane();
p.setContentType("text/rtf");
final EditorKit kitRtf = p.getEditorKitForContentType("text/rtf");
try {
kitRtf.read(new StringReader(rtf), p.getDocument(), 0);
final Writer writer = new StringWriter();
final EditorKit editorKitForContentType = p.getEditorKitForContentType("text/html");
editorKitForContentType.write(writer, p.getDocument(), 0, p.getDocument().getLength());
return writer.toString();
} catch (IOException | BadLocationException e) {
throw new RTF2HTMLException("Could not convert RTF to HTML.", e);
}
}
}
Given the code above and the following RTF string, I can't see this being converted to HTML:
The text was updated successfully, but these errors were encountered:
Robert-Rendell
changed the title
text/rtf -> text/html: Justification not converted
text/rtf -> text/html: Justification formatting not converted
Dec 8, 2020
Given the code above and the following RTF string, I can't see this being converted to HTML:
The text was updated successfully, but these errors were encountered: