This article entails how to create PowerPoint slides in HTML using Python along with the detailed configuration steps and a runnable sample code. You can generate a new presentation and export it as HTML or load an existing presentation to convert it to HTML for displaying it in a browser. In any of Python supported environments and with no dependency on MS PowerPoint or another third-party tool, you can create an HTML presentation with Python.
Steps to Create PowerPoint Slides in HTML using Python
- Establish the environment to use Aspose.Slides for Python via .NET in your application
- Import aspose.slides and aspose.pydrawing in your Python file
- Create an empty PowerPoint presentation using the Presentation class object and save it as HTML file
- Access the default first default slide in the newly created presentation
- Insert an Autoshape of Rectangle type along with setting shape and textual properties
- Save the created presentation as an HTML file
The above simple steps guide to create HTML presentation slides using Python with the help of a few API calls only. You can either create a new presentation or load an existing presentation to convert to HTML. In this example, we have focused on creating a presentation and adding an autoshape of rectangle type along with the setting of its shape and textual properties to show the contents on the output HTML page.
Code to Create HTML Presentation using Python
This code to render PowerPoint slides in HTML using Python has created a rectangle autoshape. You can further customize the shape and its text by adding hyperlinks, text paragraphs, bullets, numbered lists, media files, charts, SmartArt and WordArt etc. Similarly, while exporting to HTML, you can also select the slides that you want to render to HTML along with the option to save it to a memory stream also.
In this topic, we have learnt to convert presentation to HTML using Python. If you are interested in learning about converting slides to images, refer to the article on how to create PowerPoint slide Image using Python.