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

Free Support Forum - aspose.com

Error getting Shape coordinates from HTML file

Hi Aspose Support.

I’m having troubles getting shape coordinates. Using the following code on attached document:

NodeCollection shapeList = asposeDocument.getChildNodes(NodeType.SHAPE, true);


for (GroupShape groupShape : groupShapeList) {
LOGGER.debug("Shape type: " + shape.getShapeType());
LOGGER.debug("Shape name: " + shape.getName());
LOGGER.debug("Shape shape.getCoordOrigin().getX(): "+shape.getCoordOrigin().getX());
LOGGER.debug("Shape shape.getCoordOrigin().getY(): "+shape.getCoordOrigin().getY());

I am getting this:
[main]16:06:14.222 [DEBUG] c.b.c.c.p.impl.DocumentProcessor - Shape type: 75
[main]16:06:14.222 [DEBUG] c.b.c.c.p.impl.DocumentProcessor - Shape name:
[main]16:06:14.222 [DEBUG] c.b.c.c.p.impl.DocumentProcessor - Shape shape.getCoordOrigin().getX(): 0.0
[main]16:06:14.238 [DEBUG] c.b.c.c.p.impl.DocumentProcessor - Shape shape.getCoordOrigin().getY(): 0.0

Is it another way of getting Shape coordinates?

Thank you,
Kind regards,
Michał Wasiak

Hi Michał,

Thanks for your inquiry. You can use the following code to get the coordinates of Shape nodes:
Document doc = new Document(getMyDir() + “document.html”);

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

NodeCollection shapeList = doc.getChildNodes(NodeType.SHAPE, true);

for (Shape shape : (Iterable<Shape>) shapeList) {
System.out.println("Shape type: " + shape.getShapeType());
System.out.println("Shape name: " + shape.getName());
System.out.println("Shape shape.getCoordOrigin().getX(): " + enumerator.getRectangle().getX());
System.out.println("Shape shape.getCoordOrigin().getY(): " + enumerator.getRectangle().getY());

I hope, this helps.

Best regards,

Hi Awais,

It’s working! :slight_smile:
Thank you very much.

Best regards,
Michał Wasiak.