How to Replace or Remove Image from Extracted Pages by Document.ExtractPages using Java

Document document = new Document("file");
Document page = document.extractPages(1,1);
NodeCollection shapes = page.getChildNodes(NodeType.SHAPE, true);
Iterator shapeIterator = shapes.iterator();
                while (shapeIterator.hasNext()) {
                    Shape shape = (Shape) shapeIterator.next();
                    if (shape.hasImage()) {
                        shape.remove(); //or shape.getImageData().setImage(bufferedImage());
                    }
                 }

Trying to replace or remove image on page level.
If replace line
NodeCollection shapes = page.getChildNodes(NodeType.SHAPE, true);
with
NodeCollection shapes = document.getChildNodes(NodeType.SHAPE, true);
then everything works as expected. It is desired to replace images on specific pages.

How can it be achieved?

@lion.brotzky

Could you please ZIP and attach your input Word document here for testing? We will investigate the issue and provide you more information on it.