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

Free Support Forum - aspose.com

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);
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?


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.