This short tutorial describes how to merge shapes in PowerPoint using Java. You will learn how to set up the IDE, follow programming instructions, and use sample code to combine two shapes in PowerPoint with Java. We’ll also explain how to modify the sample code to generate the merged shapes you need in the output PPT or PPTX.
Steps to Combine Two Shapes to Make a New Shape using Java
- Set the environment to use Aspose.Slides for Java to merge shapes
- Apply the product license, create a blank presentation, and get its first slide
- Add sample shapes if no shape is available on the selected slide
- Calculate the smallest area that can hold both the shapes
- Add a new shape filling that area to hold the combined shapes
- Copy the outline of each original shape into the newly added shape, moving each outline so it stays in the same place
- Fill the merged shape with a solid blue color, remove its border, and set a text label
- Delete the original shapes, as these are already copied to the new place
- Save the presentation as a PPT or PPTX
These steps explain how to merge shapes on PowerPoint using Java. Create a blank presentation or load the existing presentation, get the first slide, add sample shapes if no shapes are present on the selected slide, calculate the bounding rectangle that can hold all the target shapes to merge, and copy the outline of each original shape into the newly added shape by following the offset. Fill the merged shape with solid blue, remove its border, set the text label, and delete the original shapes from the resultant presentation.
Code to Combine Shapes in PPT using Java
This code shows how to combine shapes in PowerPoint using Java. You can combine the outlines into one path, so the shapes join into a true outline instead of stacking on top of each other. Turn the border on or off for each outline, so only the outer edge of the merged shape shows a line.
This article explains how to merge shapes. To draw shapes in PowerPoint, refer to the article Draw shapes in PowerPoint using Java.