i’m tryping to fetch all charts and images from docx file using below code.
Document doc = new Document("C:\\Users\\DeLL\\Downloads\\MLKN_IOC_062722_WTR (1).docx");
// Get the collection of shapes from the document,
// and save the image data of every shape with an image as a file to the local file system.
NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true);
int imageIndex = 0;
for (Shape shape : (Iterable<Shape>) shapes) {
if (shape.hasImage()) {
// The image data of shapes may contain images of many possible image formats.
// We can determine a file extension for each image automatically, based on its format.
String imageFileName = MessageFormat.format("File.ExtractImages.{0}{1}", imageIndex, FileFormatUtil.imageTypeToExtension(shape.getImageData().getImageType()));
shape.getImageData().save("C:\\Users\\DeLL\\Downloads\\output1\\mlkn\\image"+imageIndex + imageFileName);
imageIndex++;
}
}
this code is working fine the the problem is for some rendered images their quality is very poor.
i’ve atteched the word file on which i’m working
MLKN_IOC_062722_WTR (1).docx (4.8 MB)