You simply add an image to the end of the document with this code. If you need this in a specific place inside the document, you need to get a descriptor on where (for example, you can find the specific P node using MainDocumentPart.getJAXBNodesViaXPath() ), and then just insert the new content at this index 'inside the document:
package.getMainDocumentPart().getContent().add(index, imageParagraph);
(You will get the value for "index" using something like MainDocumentPart.getContent().indexOf(oldParagraph) , and presumably also want to remove the found node, which is possible by calling remove() ).
source share