Fetch the image details

I have extracted the image from the document. I need more details for the extracted image. How to fetch the details(i.e Page number, height, and width).

String pdf;
NodeCollection shapes = interimdoc.getChildNodes(NodeType.SHAPE, true);
int imageIndex = 1;
for (Shape shape : (Iterable<Shape>)shapes)
{
	if (shape.hasImage())
	{
		pdf = AIE.pdfFolder + "FX" +imageIndex + ".pdf";
		Document itermDoc = (Document)interimdoc.deepClone(false);
		itermDoc.appendChild(itermDoc.importNode(shape.getAncestor(NodeType.SECTION),false,ImportFormatMode.USE_DESTINATION_STYLES));
		itermDoc.ensureMinimum();
		Node importedShape = itermDoc.importNode(shape, true, ImportFormatMode.USE_DESTINATION_STYLES);
		itermDoc.getFirstSection().getBody().getFirstParagraph().appendChild(importedShape);
		itermDoc.save(pdf);
		imageIndex++;
	}
}

kindly do the needful at the earliest

@Mahesh39 You can use LayoutCollector to get shape’s page index and Shape node properties to get it’s size:

Document doc = new Document("C:\\Temp\\in.docx");
// Create layout collector to get page number of the shape.
LayoutCollector collector = new LayoutCollector(doc);

Iterable<Shape> shapes = doc.getChildNodes(NodeType.SHAPE, true);
int imageIndex = 1;
for (Shape shape : shapes)
{
    if (shape.hasImage())
    {
        // Print the information.
        System.out.println("Shape width: " + shape.getWidth());
        System.out.println("Shape height: " + shape.getHeight());
        System.out.println("Shape page: " + collector.getStartPageIndex(shape));
    }
}
1 Like