ms word - Reading MS doc image from Java -
i want read image embedded in ms word document using java. want reconstruct image file. can suggest java library hep task?
please refer apache poi handling microsoft word files using java api's
just code snippet. check out.
import org.apache.poi.poifs.filesystem.*; import org.apache.poi.hwpf.*; import org.apache.poi.hwpf.extractor.*; import java.io.*; public class readdoc { public static void main( string[] args ) { string filesname = "hello.doc"; poifsfilesystem fs = null; try { fs = new poifsfilesystem(new fileinputstream(filesname; //couldn't close braces @ end site did not allow close hwpfdocument doc = new hwpfdocument(fs); wordextractor = new wordextractor(doc); string[] paragraphs = we.getparagraphtext(); system.out.println( "word document has " + paragraphs.length + " paragraphs" ); for( int i=0; i<paragraphs .length; i++ ) { paragraphs[i] = paragraphs[i].replaceall("\\cm?\r?\n",""); system.out.println( "length:"+paragraphs[ ].length()); } } catch(exception e) { e.printstacktrace(); }
Comments
Post a Comment