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
Post a Comment