Find and remove hidden images

I have a docx that contains hidden images.

How can I find them? I would like to remove them.

I have the following code to find and remove images, but cannot figure out if they are hidden or not.

try (InputStream stream = new ByteArrayInputStream(bytes)) {
    Document doc = new Document(stream);
    for (Object cn : doc.getChildNodes(NodeType.ANY, true))
    {
        Node node = (Node)cn;
        if (node instanceof Shape) {
        Shape shape = (Shape)node;
        if (shape.hasImage())
        {
            shape.remove();
        }
    

@kerner Could you please attach your input document for our reference? We will check the document and provide you more information.

Thank you!
Briefvorlage_empty.docx (1.1 MB)

@kerner The hidden shapes in your document are marked with docPr.hidden attribute:

<wp:docPr id="66" name="LogoSW2" hidden="1"/>

I am afraid, currently there is no public API in Aspose.Words to access this property.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-26193

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

1 Like

The issues you have found earlier (filed as WORDSNET-26193) have been fixed in this Aspose.Words for .NET 24.10 update also available on NuGet.

1 Like