How to save doc file with anchor image by using Apache POI HWPFDocument

607 views Asked by At

I am using HWPFDocument to modify some doc file. However, when I try to save a new doc file with anchor image, the image will become broken. Does any method that can handle this case? Here are some my codes.

File file = new File("testdoc.doc");
FileInputStream fis = new FileInputStream(file);
POIFSFileSystem poifs = new POIFSFileSystem(fis);
HWPFDocument doc = new HWPFDocument(poifs);

FileOutputStream out = new FileOutputStream("testtt.doc");
doc.write(out);
out.close();
doc.close();

I do not modify anything of the doc file but the anchor image still become broken.

0

There are 0 answers