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.

@ramveer,

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)

@ramveer,

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();
doc.save("E:\\doc\\awjava-19.1.docx");

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>.

@ramveer,

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();
doc.save("E:\\doc\\awjava-19.1.docx");