java - How to get picture from *.docx with all changes using POI? -


let's review relationship between "docx" , "pictures":

as understand it, *.docx stores original pictures (pictures @ moment when copy/paste them word). , every time when use picture, word makes "link" original picture.

but if make changes picture (for example resize, crop or change color) word remembers changes, modifying "link" (add special tags). that's great, because never lose quality of picture!

let's picture our *.docx file. use code snippet:

xwpfdocument worddoc = new xwpfdocument( pathtofile ); (xwpfparagraph p : worddoc.getparagraphs()) {     (xwpfrun run : p.getruns()) {         (xwpfpicture pic : run.getembeddedpictures()) {             byte [] img = pic.getpicturedata().getdata()              file  outputfile = new file ( pathtooutputfile );                             bufferedimage image = imageio.read(new bytearrayinputstream(img));             imageio.write(image , "png", outputfile);         }     } } 

but way original pictures *.docx. if, example, cropped out section picture , gave me rest, find whole image in outputfile. that's not good.

does know how picture changes made in word?


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -