title: how to put images at a certain place in the Word(.docx) file by using DOCX4J in java
body: <p>I have a requirement that I have a Word(.DOCX) file. by using a java program i need to put an image at a certain place in the document by using DOCX4J. can anyone please help me!!!</p>
  
  <p>I'm trying with the following code...</p>
  
  <pre><code> final String XPATH = "//w:t";
  String image_Path = "D:\\Temp\\ex.png";
  String template_Path = "D:\\Temp\\example.docx";
  
  WordprocessingMLPackage  package =  WordprocessingMLPackage.createPackage();
  List texts = package.getMainDocumentPart().getJAXBNodesViaXPath(XPATH, true);
  for (Object obj : texts) {
    Text text = (Text) ((JAXBElement) obj).getValue();
  
    ObjectFactory factory = new ObjectFactory();         
    P paragraph = factory.createP();         
    R run = factory.createR();         
    paragraph.getContent().add(run);         
    Drawing drawing = factory.createDrawing();         
    run.getContent().add(drawing);         
    drawing.getAnchorOrInline().add(image_Path); 
    package.getMainDocumentPart().addObject(paragraph);
    package.save(new java.io.File("D:\\Temp\\example.docx"));here
  </code></pre>