Apache POI WP

XWPFDocument doc = new XWPFDocument();
XWPFParagraph p = doc.createParagraph();

String imgFile = "aspose.jpg";
XWPFRun r = p.createRun();

int format = XWPFDocument.PICTURE_TYPE_JPEG;
r.setText(imgFile);
r.addBreak();
r.addPicture(new FileInputStream(imgFile), format, imgFile, Units.toEMU(200), Units.toEMU(200)); // 200x200 pixels

Aspose.Words

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.insertImage("data/background.jpg");
builder.insertImage("data/background.jpg",
        RelativeHorizontalPosition.MARGIN,
        100,
        RelativeVerticalPosition.MARGIN,
        200,
        200,
        100,
        WrapType.SQUARE);


Download Source Code

Many more examples are available at Aspose Docs

Last edited Sep 22, 2014 at 2:51 PM by shoaibkhan, version 2