In this simple article, we will exhibit how to create PowerPoint Presentation using Python by following the detailed steps to set up the environment and run the example on your end. You can create PowerPoint with Python and can view that in any of the presentation viewers including the MS PowerPoint. The example code can be used inside any of .NET Core supported platforms configured with Python.
Steps to Create PowerPoint Presentation using C#
- Configure the environment to set up Aspose.Slides for Python via .NET in your application
- Import aspose.pydrawing and aspose.slides in your Python file
- Generate an empty presentation using the Presentation class object
- Add a blank Slide in the slides collection using the add_empty_slide method
- Insert a Rectangle shape inside the slide using the add_auto_shape method
- Add a text frame using the add_text_frame method and apply different textual properties
- Using the Save method in Python Powerpoint presentation is generated and saved on the disk
In order to generate a customized PPTX Python API is used by adhering to the aforementioned steps. The process involves creating an empty presentation using the Presentation class and then adding a blank slide inside the slides collection. A Rectangle autoshape is created which is filled with some text by adding a text frame to the shape and setting the textual properties before saving the generated presentation on the disk.
Code to Create PowerPoint With Python
By using the above example in Python Presentation in PPTX format has been created on the disk. The SaveFormat enumerator provides options to save the presentation in PPT, PPS, PPSX, ODP, POT and POTX formats as well. The text inside the slide shape can be further customized by using different properties available in the PortionFormat and the ParagraphFormat classes, including setting the paragraphs bullets, text indentations, margins, underlining and highlighting the text.
In this example, we have seen that in order to create a PPTX presentation Python based API can be used with no reliance on MS PowerPoint. If you are interested in converting a presentation to a PDF, refer to the article on how to convert Presentation to PDF using Python.