Add image into a word .docx document header using

2019-09-04 19:41发布

Can anyone please help me to add image into word document (.docx) header using Apache POI's XWPF component?.

I tried very hard, but unable to find solution.

1条回答
我命由我不由天
2楼-- · 2019-09-04 20:34
XWPFDocument doc = new XWPFDocument();

FileInputStream fis = new FileInputStream("/images/image.png"); 
XWPFParagraph par1 = doc.createParagraph();
XWPFRun runAppName = par1.createRun();  
runAppName.addPicture(fis, Document.PICTURE_TYPE_PNG, "image.png", 257, 185);

doc.write(new FileOutputStream(new File("/folder/document.docx")));
查看更多
登录 后发表回答