3D effects in PowerPoint presentations make the content more attractive. Using 3D text or shapes, you can enhance the interactivity and catch the attention of the audience. While working on the automation of PowerPoint from within .NET applications, you may need to add 3D effects to the presentations. To accomplish that, this article covers how to apply the 3D effects in PowerPoint PPT in C#.
- .NET API to Create 3D Effects in PowerPoint
- Create a 3D Text in PowerPoint in C#
- Create a 3D Shape in PowerPoint in C#
- Set Gradient for 3D Shapes
- Apply 3D Effects to an Image in PowerPoint
.NET API to Apply 3D Effects in PowerPoint
Aspose.Slides for .NET is an amazing API that provides a range of features to implement PowerPoint automation. Using the API, you can create and manipulate presentations seamlessly. We will use this API to apply 3D effects in the PowerPoint presentations. You can either download API’s DLL or install it using NuGet.
PM> Install-Package Aspose.Slides.NET
Create a 3D Text in PowerPoint in C#
The following are the steps to create a 3D text fragment in PowerPoint PPT using C#.
- 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 properties in TextFrame.TextFrameFormat.ThreeDFormat.
- Finally, save presentation using Presentation.Save(String, SaveFormat) method.
The following code sample shows how to create a 3D text in PowerPoint in C#.
The following screenshot shows output of the code sample above.
Create a 3D Shape in PowerPoint in C#
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 in C#.
- First, create a new PPT using Presentation class.
- Add a new rectangle shape using AddAutoShape() method.
- Set shape’s text using Shape.TextFrame.Text property.
- Apply 3D effects to shape using properties in IAutoShape.ThreeDFormat.
- Finally, save presentation using Presentation.Save(String, SaveFormat) method.
The following code sample shows how to apply 3D effects to shapes in PowerPoint using C#.
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 Shape.TextFrame.Text property.
- Set IAutoShape.FillFormat.FillType to FillType.Gradient and set gradient colors.
- Apply 3D effects to shape using properties in IAutoShape.ThreeDFormat.
- Finally, save presentation using Presentation.Save(String, SaveFormat) method.
The following code sample shows how to apply gradient effects to shapes in PowerPoint.
The following is the 3D shape after applying the gradient effect.
Apply 3D Effects to an Image in PowerPoint in C#
Aspose.Slides for .NET also allows you to apply 3D effects to an image. The following are the steps to perform this operation in C#.
- Create a new PPT using Presentation class.
- Add a new rectangle shape using AddAutoShape() method.
- Set IAutoShape.FillFormat.FillType to FillType.Picture and add image.
- Apply 3D effects to shape using properties in IAutoShape.ThreeDFormat.
- Save presentation using Presentation.Save(String, SaveFormat) method.
The following are the steps to apply 3D effects to an image in PPT using C#.
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 .NET without evaluation limitations.
Conclusion
In this article, you have learned how to apply 3D effects in PowerPoint presentations using C#. We have covered how to create 3D text or shapes and apply 3D effects to images in PPT or PPTX presentations. In case you want to explore more about Aspose.Slides for .NET, you can visit the documentation. Also, you can post your queries to our forum.