Group Shapes in PowerPoint in Java

Import JAR Dependency (2 Methods)

<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>http://repo.e-iceblue.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.presentation.free</artifactId>
<version>5.1.0</version>
</dependency>
</dependencies>

Sample Code

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.LIGHT_YELLOW);
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.LIGHT_BLUE);
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);
}
}

--

--

--

Sharing Java Code

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

The Feren OS (with Cinnamon) ISOs are now based on Linux Mint 19.2

7 tips on how to write kick-ass high performance Golang microservices

Redesigning of Ballerina Cache

Migration of CentOs8 to RockyLinux

Book Launch: “Data Science in Production”

Weekly Digest #10

Develop Mobile Apps On a Chromebook…Really!

BUILDING YOUR CUSTOM CRM

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrew Wilson

Andrew Wilson

Sharing Java Code

More from Medium

Fundamentals of Java

Can there be static imports in Java

Return nothing, with Java Optionals

Datatypes . What are they?