java - how to extract image from rtf file using RTFEditorKit -


using coding html extracted. need extract image rtf. think problem in rtfeditorkit. please suggest ideas solve this.

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;   } 

standard rtfeditorkit not support images. can use alternative advancedrtfeditorkit. read document , go through character elements checking attributes images.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -