Hi Team,
Can anyone please guide me on how to check whether the image is present or not and find their page number?
Thanks in advance
Hi Team,
Can anyone please guide me on how to check whether the image is present or not and find their page number?
Thanks in advance
@Mahesh39 Images in MS Word document are represented as Shape
node. You can loop through all shapes in your document and use LayoutCollector to get page number of each shape with image. For example see the following code:
Document doc = new Document("C:\\Temp\\in.docx");
// Layout collector can be used to get page number of a particular node
LayoutCollector collector = new LayoutCollector(doc);
// Get all shapes.
Iterable<Shape> shapes = doc.getChildNodes(NodeType.SHAPE, true);
for (Shape s: shapes)
{
// Check whether shape has an image.
if (s.hasImage())
System.out.println(collector.getStartPageIndex(s));
}