Position and dimensions of a Shape inside a GroupShape is in the coordinate space and units of the parent group

Hello. I’m working with a Word document that contains grouped absolute position text boxes, and I’m attempting to get their values.

I use shape.getWidth() , shape.getHeight() , shape.getLeft() , and shape.getTop() on shapes within a group. The documentation states that "For shapes in a group, the value is in the coordinate space and units of the parent group." However, I’m struggling to translate these values back to the document’s coordinate space and units.

For instance, in the Word document, the height of one grouped shape (shape1) is 0.84 inches, and another grouped shape (shape2) is 1.73 inches. But the output from shape1.getHeight() is 768096.0 points, which converts to 10668 inches, and shape2.getHeight() is 1581912.0 points, translating to 21971 inches. Meanwhile, the parent GroupShape groupShape.getHeight() gives the correct result. When shapes are not inside a group the result is correct as well.
How can I convert and use the values of grouped shapes to position them correctly in the document?

@Martin123 Could you please provide your document? We will investigate the issue and provide you more information.

example group with 2 blocks.docx (19.3 KB)

@Martin123 need to use values from BoundsInPoints:

Shape shape = (Shape) doc.getChild(NodeType.SHAPE, 0, true);
Assert.assertEquals(0.84, ConvertUtil.pointToInch(shape.getBoundsInPoints().getHeight()), 0.01);
1 Like