Convert Presentations to HTML5 in Python via Java
Overview
This article explains how to convert PowerPoint presentations to HTML5 using Aspose.Slides. It covers basic HTML5 export without additional web extensions, as well as options for controlling shape animations and slide transitions. The article also shows the standard PowerPoint-to-HTML export process, explains how to generate HTML5 output in slide view mode, and demonstrates how to include comments in the exported document by configuring their layout.
The examples require Aspose.Slides for Python via Java and a compatible Java runtime. Place pres.pptx (or sample.pptx for the comments example) in the current working directory. Each example starts the JVM only if it is not already running.
Export PowerPoint to HTML5
Use Presentation.save with SaveFormat.Html5 to export a presentation without additional web extensions:
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import Presentation, SaveFormat
presentation = Presentation("pres.pptx")
try:
presentation.save("pres.html", SaveFormat.Html5)
finally:
presentation.dispose()
Note
The HTML5 exporter creates HTML content for viewing in a browser.Use Html5Options to configure the export. Call setAnimateShapes and setAnimateTransitions with False to disable shape animations and slide transitions:
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import Html5Options, Presentation, SaveFormat
presentation = Presentation("pres.pptx")
try:
html5_options = Html5Options()
html5_options.setAnimateShapes(False)
html5_options.setAnimateTransitions(False)
presentation.save("pres5.html", SaveFormat.Html5, html5_options)
finally:
presentation.dispose()
Export PowerPoint to HTML
Use SaveFormat.Html for standard HTML export. See Convert PowerPoint to HTML for more options:
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import Presentation, SaveFormat
presentation = Presentation("pres.pptx")
try:
presentation.save("pres.html", SaveFormat.Html)
finally:
presentation.dispose()
In this case, the presentation content is rendered through SVG in a form like this:
<body>
<div class="slide" name="slide" id="slideslideIface1">
<svg version="1.1">
<g> THE SLIDE CONTENT GOES HERE </g>
</svg>
</div>
</body>
Warning
Standard HTML export renders slide content through SVG and does not provide the HTML5 shape-animation and slide-transition options.Export PowerPoint to HTML5 Slide View
Aspose.Slides allows you to convert a PowerPoint presentation to an HTML5 document in which the slides are presented in a slide view mode. In this case, when you open the resulting HTML5 file in a browser, you see the presentation in slide view mode on a web page.
This Python code demonstrates the PowerPoint to HTML5 Slide View export process:
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import Html5Options, Presentation, SaveFormat
presentation = Presentation("pres.pptx")
try:
html5_options = Html5Options()
html5_options.setAnimateShapes(True)
html5_options.setAnimateTransitions(True)
presentation.save("HTML5-slide-view.html", SaveFormat.Html5, html5_options)
finally:
presentation.dispose()
Convert Presentations to HTML5 Documents with Comments
Comments in PowerPoint are a tool that allows users to leave notes or feedback on presentation slides. They are especially useful in collaborative projects, where multiple people can add their suggestions or remarks to specific slide elements without altering the main content. Each comment shows the author’s name, making it easy to track who left the remark.
Let’s say we have the following PowerPoint presentation saved in the “sample.pptx” file.

When you convert a PowerPoint presentation to an HTML5 document, you can easily specify whether to include comments from the presentation in the output document. To do this, pass the display parameters for comments to the setSlidesLayoutOptions method of the Html5Options class.
Use NotesCommentsLayoutingOptions and setCommentsPosition with CommentsPositions.Right. The following code example converts a presentation to an HTML5 document with comments displayed to the right of the slides.
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import CommentsPositions, NotesCommentsLayoutingOptions, Html5Options, Presentation, SaveFormat
presentation = Presentation("sample.pptx")
try:
layout_options = NotesCommentsLayoutingOptions()
layout_options.setCommentsPosition(CommentsPositions.Right)
html5_options = Html5Options()
html5_options.setSlidesLayoutOptions(layout_options)
presentation.save("output.html", SaveFormat.Html5, html5_options)
finally:
presentation.dispose()
The “output.html” document is shown in the image below.

FAQ
Can I control whether object animations and slide transitions will play in HTML5?
Yes, HTML5 provides separate options to enable or disable shape animations and slide transitions.
Can comments be exported, and where can they be placed relative to the slide?
Yes, comments can be added in HTML5 and positioned (for example, to the right of the slide) through layout settings for notes and comments.
Can I skip links that invoke JavaScript for security or CSP reasons?
Yes, there is a setting that allows you to skip hyperlinks with JavaScript calls during saving. This removes those hyperlinks; it does not by itself guarantee that all generated HTML5 scripts satisfy a site’s Content Security Policy.