I\'ve created a simple docx-Document, using Java POI 3.7. XWPF. Then, I added a picture by
using the Method XWPFDocument.addpicture(byte[] arg0, int arg1)
. >
The elegant solution is coming, check out: https://issues.apache.org/bugzilla/show_bug.cgi?id=55476
You can either wait till my patch gets accepted and released or try applying the patch to the latest POI SVN checkout (http://poi.apache.org/subversion.html, read only access link will work) and building POI jars from sources.
The approach suggested by tsd.tom will work:
XWPFParagraph par = docx.createParagraph();
XWPFRun run = par.createRun();
run.addPicture(pic, XWPFDocument.PICTURE_TYPE_JPEG, "logo.JPG",300,300);