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

Free Support Forum - aspose.com

Remove All Images from a uploaded Word Document

I am not able to remove all the image/shape from word document .
i am using below code to remove but it is not working in case of pict image tag:- doc.getChildNodes(NodeType.SHAPE, true).clear();
Could you Please suggest the code to remove all image/shape from uploaded word document.


The following line of code should work when using the latest version of Aspose.Words for Java i.e. 19.1:

doc.getChildNodes(NodeType.SHAPE, true).clear();

In case the problem still remains, please ZIP and upload your input Word document (you are getting this problem with) here for testing. We will then investigate the issue on our end and provide you more information.

issue still persist with latest version of Aspose.Words for Java i.e. 19.1.
This issue is due to <w:pict> tag.
sample document attached doc.zip (167.0 KB)


We have produced this document awjava-19.1.zip (105.7 KB) by using the following code:

Document doc = new Document("E:\\doc\\65 pages.docx");
doc.getChildNodes(NodeType.SHAPE, true).clear();

Can you see the image in this ‘awjava-19.1.docx’ document? If yes, please share on what location (page) we can observe it too?

You can reproduce the exception issue
if you try to save the given word document in html format
doc.save(output, SaveFormat.HTML);
then you get the exception:

oracle.apps.fnd.framework.OAException: java.lang.IllegalStateException: Image file cannot be written to disk. When saving the document to a stream either ImagesFolder should be specified or custom streams should be provided via ImageSavingCallback. Please see documentation for details.

Note:It is not visible image , if you convert given word document into .xml format and open in Notepad++, you are able to see the the tag <w:pict>.


There is one GroupShape object underneath the text “List of Sections Affected” that you can remove by using the following code:

Document doc = new Document("E:\\doc\\65 pages.docx");
doc.getChildNodes(NodeType.GROUP_SHAPE, true).clear();