MS PowerPoint provides 3D effects to make the presentations more attractive. You can use 3D text, shapes, and images to enhance the interactivity of the content. In this article, you will learn how to apply the 3D effects in PowerPoint PPT programmatically in Python. We will cover how to create 3D effects for text, shapes, and images in the presentations.
- Python Library to Create 3D Effects in PowerPoint
- Create a 3D Text in PowerPoint in Python
- Create a 3D Shape in PowerPoint in Python
- Set Gradient for 3D Shapes
- Apply 3D Effects to an Image in PowerPoint
Python Library to Apply 3D Effects in PowerPoint
Aspose.Slides for Python via .NET is a feature-rich Python library that is designed to create and manipulate PowerPoint presentations. We will use this library to apply 3D effects in the PowerPoint PPT/PPTX presentations. Use the following command to install the library from PyPI.
> pip install aspose.slides
Create a 3D Text in PowerPoint in Python
The following are the steps to create a 3D text fragment in PowerPoint PPT using Python.
- First, create a new PPT or load existing one using Presentation class.
- Then, add a new rectangle shape using add_auto_shape() method.
- Set shape’s properties such as fill type, text, etc.
- Get reference of the text portion inside shape into an object.
- Apply formatting to the text portion.
- Get reference of the text_frame inside shape.
- Apply 3D effects using properties in text_frame.text_frame_format.three_dformat.
- Finally, save presentation using Presentation.save(String, SaveFormat) method.
The following code sample shows how to create a 3D text in PowerPoint in Python.
The following screenshot shows the output of the code sample above.
Create a 3D Shape in PowerPoint in Python
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 Python.
- First, create a new PPT using Presentation class.
- Then, add a new rectangle shape using add_auto_shape() method.
- Set shape’s text using shape.text_frame.text property.
- Apply 3D effects to shape using properties in shape.three_dformat.
- Finally, save presentation using Presentation.save(String, SaveFormat) method.
The following code sample shows how to apply 3D effects to shapes in PowerPoint using Python.
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.
- Then, add a new rectangle shape using add_auto_shape() method.
- Set shape’s text using shape.text_frame.text property.
- Set shape.fill_format.fill_type to FillType.GRADIENT and set gradient colors.
- Apply 3D effects to shape using properties in shape.three_dformat.
- 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 Python
You can also apply 3D effects to the images in the PowerPoint presentations. The following are the steps to perform this operation in Python.
- Create a new PPT using Presentation class.
- Then, add a new rectangle shape using add_auto_shape() method.
- Set shape.fill_format.fill_type to FillType.PICTURE and add image.
- Apply 3D effects to shape using properties in shape.three_dformat.
- Save presentation using Presentation.save(String, SaveFormat) method.
The following are the steps to apply 3D effects to an image in PPT using Python.
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 Python via .NET without evaluation limitations.
Conclusion
In this article, you have learned how to apply 3D effects in PowerPoint presentations using Python. 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 Python via .NET, you can visit the documentation. Also, you can post your queries to our forum.