Convert PPT to HTML in Python

In various cases, you have to convert the slides in PowerPoint presentations to HTML. For example, to view in browser, to index the content, etc. In this article, you will learn how to convert PowerPoint PPT or PPTX to HTML in Python. Moreover, we will cover how to convert PPT to responsive HTML and include slide notes in resultant HTML pages.

Python PowerPoint PPT to HTML Converter

Aspose.Slides for Python via .NET is a powerful Python library that provides a wide range of presentation manipulation features. You can create new presentations from scratch or manipulate the existing ones seamlessly without MS Office. In addition, it provides a high fidelity conversion of PPT/PPTX to other formats. We will use this library to convert PPT to HTML. You can install it in your Python application from PyPI using the following command.

> pip install aspose.slides

Info: Besides converting PowerPoint to HTML, Aspose.Slides allows you to convert HTML to PDF, convert HTML to PPT, convert HTML to JPG, convert HTML to XML, convert HTML to TIFF. Similarly, you can use it to import HTML from PPT, get it from PDF, etc.

Convert a PowerPoint PPT/PPTX to HTML in Python

The following are the steps to convert a PowerPoint PPT to HTML in Python.

  • Load the PPT (or PPTX) file using Presentation class.
  • Convert PPT to HTML using Presentation.save(string, export.SaveFormat.HTML) method.

The following code sample shows how to convert a PowerPoint PPTX file to HTML in Python.

The following is the HTML page that we get after converting a PPT having two slides.

Converting a PowerPoint PPT to HTML in Python

Convert PPT or PPTX to Responsive HTML in Python

You can also convert a PPT file to responsive HTML so that it appears properly on different browsers and screen sizes. The following are the steps to achieve this.

  • Load the PPT (or PPTX) file using Presentation class.
  • Create an object of HtmlOptions class.
  • Create an object of ResponsiveHtmlController class.
  • Assign controller to HtmlOptions.html_formatter property.
  • Convert PPT to HTML using Presentation.save(string, export.SaveFormat.HTML, HtmlOptions) method.

The following code sample shows how to convert a PPTX to responsive HTML in Python.

The following screenshot shows how the converted HTML appears on a mobile screen.

Conversion of PowerPoint PPTX to responsive HTML

Include Slide Notes in PowerPoint to HTML Conversion

By default, the slide notes are not included in the converted HTML pages. However, if you want to include them, you can do it by assigning a value from export.NotesPositions enum to HtmlOptions.notes_comments_layouting.notes_position property. The following code sample shows how to include slide notes at bottom of the HTML pages.

The following screenshot shows how the slide notes appear on the converted HTML page.

Rendering Slides Notes in PPT to HTML in Python

Get a Free License

You can use Aspose.Slides for Python via .NET without evaluation limitations by getting a temporary license.

Conclusion

In this article, you have learned how to convert PowerPoint PPT or PPTX to HTML in Python. Furthermore, we have seen how to convert a presentation to responsive HTML and include slide notes in the resultant HTML pages. You can read more about Aspose.Slides for Python via .NET using the documentation. In case of any questions, reach us at our forum.

See Also

Info: Aspose provides a free PowerPoint to HTML conversion service, which is a live implementation of the presentation to HTML conversion process.