3D effects in PowerPoint are used to make the presentations more attractive and catch users’ attention Therefore, you may come across the requirement of adding 3D objects to presentations programmatically. In this article, you will learn how to create 3D effects in PowerPoint PPT or PPTX in Java. We will show you how to create 3D text and shapes and apply 3D effects to images.
- Java API to Create 3D Effects in PowerPoint
- Create a 3D Text in PowerPoint in Java
- Create a 3D Shape in PowerPoint in Java
- Set Gradient for 3D Shapes
- Apply 3D Effects to an Image in PowerPoint
Java API to Apply 3D Effects in PowerPoint PPT
Aspose.Slides for Java is a powerful API encapsulating a wide range of presentation manipulation features. Using the API, you can create interactive presentations and manipulate existing PPT/PPTX files seamlessly. To create 3D effects in the PowerPoint presentations, we will utilize this API.
You can either download API’s JAR or install it using the following Maven configurations.
Repository:
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://repository.aspose.com/repo/</url>
</repository>
Dependency:
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-slides</artifactId>
<version>22.1</version>
<classifier>jdk16</classifier>
</dependency>
Create a 3D Text in PowerPoint in Java
The following are the steps to create a 3D text fragment in PowerPoint PPT using Java.
- First, create a new PPT or load existing one using Presentation class.
- Then, add a new rectangle shape using addAutoShape() method.
- Set shape’s properties such as fill type, text, etc.
- Get reference of the text inside shape into a Portion object.
- Apply formatting to the text portion.
- Get reference of the TextFrame inside shape.
- Apply 3D effects using IThreeDFormat returned by TextFrame.getTextFrameFormat().getThreeDFormat() method.
- Finally, save presentation using Presentation.save(String, SaveFormat) method.
The following code sample shows how to create 3D text in PowerPoint PPT in Java.
The following screenshot shows the output of the code sample above.
Create a 3D Shape in PowerPoint in Java
Similar to text, you can apply 3D effects to the shapes in PowerPoint presentations. The following are the steps to create a 3D shape in PowerPoint PPT using Java.
- First, create a new PPT using Presentation class.
- Add a new rectangle shape using addAutoShape() method.
- Set shape’s text using IAutoShape.getTextFrame.setText() method.
- Apply 3D effects to shape using IThreeDFormat returned by IAutoShape.getThreeDFormat() method.
- Finally, save presentation using Presentation.save(String, SaveFormat) method.
The following code sample shows how to apply 3D effects to shapes in PowerPoint using Java.
The following is the 3D shape that we get after executing this code.
Create Gradient for 3D Shapes
You can also apply gradient effects to the shapes following the steps below.
- First, create a new PPT using Presentation class.
- Add a new rectangle shape using addAutoShape() method.
- Set shape’s text using IAutoShape.getTextFrame().setText() property.
- Set fill type of shape to FillType.Gradient and set gradient colors.
- Apply 3D effects to shape using IThreeDFormat returned by IAutoShape.getThreeDFormat() method.
- Finally, save presentation using Presentation.save(String, SaveFormat) method.
The following code sample shows how to apply gradient effects to shapes in a PowerPoint PPT.
The following is the 3D shape after applying the gradient effect.
Apply 3D Effects to an Image in PowerPoint in Java
Aspose.Slides for Java also allows you to apply 3D effects to an image. The following are the steps to perform this operation in Java.
- Create a new PPT using Presentation class.
- Add a new rectangle shape using addAutoShape() method.
- Set fill type of the shape to FillType.Picture and add image.
- Apply 3D effects to shape using IThreeDFormat returned by IAutoShape.getThreeDFormat() method.
- Save presentation using Presentation.save(String, SaveFormat) method.
The following are the steps to apply 3D effects to an image in PPT using Java.
The following is the resultant image that we get after applying 3D effects.
Get a Free License
You can get a free temporary license to use Aspose.Slides for Java without evaluation limitations.
Conclusion
In this article, you have learned how to apply 3D effects in PowerPoint PPT/PPTX using Java. With the help of code samples, we have demonstrated how to create 3D text or shapes and apply 3D effects to images in PPT or PPTX presentations. You can visit the documentation to explore more about Aspose.Slides for Java. Also, you can post your questions or queries to our forum.