I'm using Apache POI 3.16 (the latest version at the time of writing). In the following snippet, I create a XSLFGroupShape which I then use to create a bunch of child shapes:
XSLFGroupShape group = slide.createGroup();
XSLFAutoShape cardRect = group.createAutoShape();
cardRect.setShapeType(ShapeType.RECT);
cardRect.setAnchor(rect);
XSLFPictureShape avatarShape = group.createPicture(avatar);
// More shapes added to the group here...
The problem is the following: in the generated PowerPoint file, the group position and dimensions appear to be uninitialized (I've selected the rectangle whose content is pixelated; the whole rectangle and its content is a single XSLFGroupShape; notice the group's manipulator at the top-left corner of the slide):
Am I missing anything in my code? Is there a way to circumvent or fix this problem?
The
GroupShape
needs anAnchor
and anInteriorAnchor
. And the grouped shapes must fit into theGroupShape
. ThePowerPoint
GUI does managing that automatically while the user is working with groups. Butapache poi
needs correct settings for this since it simply writes into the file what the program says.Example: A group shape in width 350, height 300, left 100, top 50 and a simple shape in each of it's corners.