Free Support Forum - aspose.com

Need to remove an image from word document


#1

We have an image in the word document we need to remove in some cases. We bookmarked it and tried this:

BookmarkCollection bookmarks = doc.getRange().getBookmarks();
Bookmark plus = bookmarks.get("plusimage");
Shape plusShape = (Shape) plus.getBookmarkStart().getAncestor(NodeType.);
plusShape.remove();

But we got a null pointer exception on the last line. We wondering if we cast this to the right object or if there is some better way to remove the image.


#2

@ganeshtech,
Please share your sample document file with us for our analysis. We will test it here and provide feedback accordingly.