仅使用此编码html将被提取。但我需要从rtf中提取图像。我认为问题出在RTFEditorKit上。请提出您的想法以解决此问题。
private static String rtfToHtml(Reader rtf) throws IOException {
JEditorPane p = new JEditorPane();
p.setContentType("text/rtf");
RTFEditorKit kitRtf = (RTFEditorKit) p.getEditorKitForContentType("text/rtf");
try {
kitRtf.read(rtf, p.getDocument(), 0);
kitRtf = null;
EditorKit kitHtml = p.getEditorKitForContentType("text/html");
Writer writer = new StringWriter();
kitHtml.write(writer, p.getDocument(), 0, p.getDocument().getLength());
return writer.toString();
} catch (BadLocationException e) {
e.printStackTrace();
}
return null;
}