This article demonstrates how to group shapes in a PowerPoint document using Spire.Presentation for Java.
import com.spire.presentation.*; import com.spire.presentation.drawing.FillFormatType; import java.awt.geom.Rectangle2D; import java.util.ArrayList; public class GroupShapes { public static void main(String[] args) throws Exception { //create a PowerPoint document Presentation ppt = new Presentation(); //get the first slide ISlide slide = ppt.getSlides().get(0); //add a rectangle shape to the slide IShape rectangle = slide.getShapes().appendShape(ShapeType.RECTANGLE, new Rectangle2D.Double(20,100,200,40)); rectangle.getFill().setFillType(FillFormatType.SOLID); rectangle.getFill().getSolidColor().setKnownColor(KnownColors.GOLD); rectangle.getLine().setWidth(0.1f); //add a ribbon shape to the slide IShape ribbon = slide.getShapes().appendShape(ShapeType.RIBBON_2, new Rectangle2D.Double(60, 75, 120, 80)); ribbon.getFill().setFillType(FillFormatType.SOLID); ribbon.getFill().getSolidColor().setKnownColor(KnownColors.PURPLE); ribbon.getLine().setWidth(0.1f); //add the shapes to a list ArrayList list = new ArrayList(); list.add((Shape)rectangle); list.add((Shape)ribbon); //group the shapes ppt.getSlides().get(0).groupShapes(list); //save the resultant document ppt.saveToFile("GroupShapes.pptx", FileFormat.PPTX_2013); } }