Detecting overlapping images and/or shapes

Dear team,

How can I detect if two images/shapes are overlapping each other using Aspose Word java API?
The overlapping should only return true if the images are effectively on the same page.
Is this a example somewhere for this?

Many thanks.

Patrick

@PatrickVB,

Thanks for your inquiry. The Aspose.Words.Layout namespace provides classes that allow to access information such as on what page and where on a page particular document elements are positioned, when the document is formatted into pages. Please read the members of LayoutCollector and LayoutEnumerator classes.

Please use the following code example to check either shapes are overlapped or not. Hope this helps you.

Document doc = new Document(MyDir + "Page.docx");

Shape shape1 = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
Shape shape2 = (Shape)doc.getChild(NodeType.SHAPE, 1, true);

LayoutCollector collector = new LayoutCollector(doc);
LayoutEnumerator layoutEnumerator = new LayoutEnumerator(doc);

Object renderObject = collector.getEntity(shape1);
layoutEnumerator.setCurrent(renderObject);

Rectangle2D.Float rectange1 =  layoutEnumerator.getRectangle();

renderObject = collector.getEntity(shape2);
layoutEnumerator.setCurrent(renderObject);

Rectangle2D.Float rectange2 =  layoutEnumerator.getRectangle();

System.out.println(rectange1.intersects(rectange2));