We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Builder.insertImage � does not insert image for �TOP_BOTTOM� wrap type


Please see the following code snippet and the attached document we are trying to use to insert an image (an image is attached too). When using version 15.12.0 and wrapType “TOP_BOTTOM”, the image does not insert. It works OK for “INLINE” wrap type.

When we use an older version, 14.8, the image inserts OK with both wrap types.

Document doc = new Document("/data/insertImage-Test.docx");
DocumentBuilder builder = new DocumentBuilder(doc);

FileInputStream image = new FileInputStream( "/data/star.jpg");
builder.moveToBookmark("cover_image", true, false );
builder.insertImage( image, RelativeHorizontalPosition.DEFAULT, 0.0, RelativeVerticalPosition.PARAGRAPH, 0.0, ConvertUtil.inchToPoint(7.5), ConvertUtil.inchToPoint(10), WrapType.TOP_BOTTOM);

OoxmlSaveOptions saveOptions = new OoxmlSaveOptions( SaveFormat.DOCX );
saveOptions.setCompliance( OoxmlCompliance.ISO_29500_2008_TRANSITIONAL );
doc.save("/data/InsertImageTest-output.docx", saveOptions);

Also, please note, that the issue occurs when inserting an image inside of a shape. Works OK when inserting directly to the document body.

Please let me know if this issue can be fixed or if there is anything on our side that can be done to avoid the problem.



Hi Natasa,

Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word does. You are inserting an image (Shape node) inside Shape node. MS Word also does not allow to set wrap type of shape node inside another Shape node. To check this behavior, please open your input document in MS Word and move the cursor to the bookmark. Insert the image and try to set the wrap type of shape.

Please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information on this along with code.