I have this code:
XWPFParagraph title = document.createParagraph();
XWPFRun run = title.createRun();
title.setAlignment(ParagraphAlignment.CENTER);
String imgFile = "C:\Users\Leath\Documents\NetBeansProjects\usuario_1\src\imagenes\encabezado.png";
FileInputStream is = new FileInputStream(imgFile);
run.addBreak();
run.addPicture(is, XWPFDocument.PICTURE_TYPE_JPEG, imgFile, Units.toEMU(500), Units.toEMU(50));
run.addBreak();
is.close();
But as you can see, I am only creating a paragraph and I would like it to generate the word, generate the image in the header, or learn to write a template in Word