Render PowerPoint presentations as HTML, PDF, and image files

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Viewer MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-viewer -- dnx GroupDocs.Viewer.Mcp --yes
Folders, licensing and more →

GroupDocs.Viewer for Python allows you to render your presentations in HTML, PDF, PNG, and JPEG formats. You do not need to use Microsoft PowerPoint or other software to load and view presentations within your Python application (web or desktop).

Create a Viewer class instance to get started with the GroupDocs.Viewer API. Pass a presentation you want to view to the class constructor. You can load the presentation from a file or stream. Call one of the Viewer.view method overloads to convert the presentation to HTML, PDF, or image format. These methods allow you to render the entire presentation or specific slides.

View PowerPoint files online View demos and examples on GitHub

Supported Presentation file formats

GroupDocs.Viewer supports the following file formats:

Render presentations as HTML

Create an HtmlViewOptions.for_embedded_resources class instance and pass it to the Viewer.view method to convert a presentation file to HTML. The HtmlViewOptions class properties allow you to control the conversion process. For instance, you can embed all external resources in the generated HTML file, minify the output file, and optimize it for printing. Refer to the following documentation section for details: Rendering to HTML.

Create an HTML file with embedded resources

To save all elements of an HTML page (including text, graphics, and stylesheets) into a single file, call the HtmlViewOptions.for_embedded_resources method and specify the output file name.

from groupdocs.viewer import Viewer
from groupdocs.viewer.options import HtmlViewOptions

def render_presentation_to_html():
    # Load presentation
    with Viewer("sample.pptx") as viewer:
        # Create an HTML file for each slide.
        # {0} is replaced with the current page number in the file name.
        options = HtmlViewOptions.for_embedded_resources("render_presentation_to_html/pdf_page_{0}.html")
        viewer.view(options)

if __name__ == "__main__":
    render_presentation_to_html()

sample.pptx is the sample file used in this example. Click here to download it.

render_presentation_to_html/pdf_page_1.html (467 KB)
render_presentation_to_html/pdf_page_2.html (329 KB)
render_presentation_to_html/pdf_page_3.html (344 KB)
render_presentation_to_html/pdf_page_4.html (343 KB)
render_presentation_to_html/pdf_page_5.html (333 KB)
render_presentation_to_html/pdf_page_6.html (330 KB)

Download full output

Create an HTML file with external resources

If you want to store an HTML file and additional resource files (such as fonts, images, and stylesheets) separately, call the HtmlViewOptions.for_external_resources method and pass the following parameters:

  • The output file path format
  • The path format for the folder with external resources
  • The resource URL format
from groupdocs.viewer import Viewer
from groupdocs.viewer.options import HtmlViewOptions

def render_presentation_to_html_external():
    # Load presentation
    with Viewer("sample.pptx") as viewer:
        # Create an HTML file for each slide.
        # Specify the HTML file names and location of external resources.
        # {0} and {1} are replaced with the current page number and resource name, respectively.
        # The resource URL is relative to the HTML file.
        viewOptions = HtmlViewOptions.for_external_resources("render_presentation_to_html_external/pdf_page_{0}.html", "render_presentation_to_html_external/pdf_page_{0}/resource_{0}_{1}", "pdf_page_{0}/resource_{0}_{1}")
        viewer.view(viewOptions)

if __name__ == "__main__":
    render_presentation_to_html_external()

sample.pptx is the sample file used in this example. Click here to download it.

render_presentation_to_html_external/pdf_page_1.html (259 bytes)
render_presentation_to_html_external/pdf_page_1/resource_1_g.svg (4 KB)
render_presentation_to_html_external/pdf_page_1/resource_1_i.jpg (100 KB)
render_presentation_to_html_external/pdf_page_1/resource_1_i.png (5 KB)
render_presentation_to_html_external/pdf_page_2.html (259 bytes)
render_presentation_to_html_external/pdf_page_2/resource_2_g.svg (6 KB)
render_presentation_to_html_external/pdf_page_3.html (259 bytes)
render_presentation_to_html_external/pdf_page_3/resource_3_g.svg (20 KB)
render_presentation_to_html_external/pdf_page_4.html (259 bytes)
render_presentation_to_html_external/pdf_page_4/resource_4_g.svg (19 KB)
[TRUNCATED] (14 files total)

Download full output

External resources are placed in a separate folder.

Render presentations as PDF

Create a PdfViewOptions class instance and pass it to the Viewer.view method to convert a presentation file to PDF. The PdfViewOptions class properties allow you to control the conversion process. For instance, you can protect the output PDF file, reorder its pages, and specify the quality of document images. Refer to the following documentation section for details: Rendering to PDF.

from groupdocs.viewer import Viewer
from groupdocs.viewer.options import PdfViewOptions

def render_presentation_to_pdf():
    # Load presentation
    with Viewer("sample.pptx") as viewer:
        viewOptions = PdfViewOptions("render_presentation_to_pdf/presentation.pdf")
        viewer.view(viewOptions)

if __name__ == "__main__":
    render_presentation_to_pdf()

sample.pptx is the sample file used in this example. Click here to download it.

Binary file (PDF, 375 KB)

Download full output

Render presentations as PNG

Create a PngViewOptions class instance and pass it to the Viewer.view method to convert a presentation file to PNG. Use the PngViewOptions.height and PngViewOptions.width methods to specify the output image size in pixels.

from groupdocs.viewer import Viewer
from groupdocs.viewer.options import PngViewOptions

def render_presentation_to_png():
    # Load presentation
    with Viewer("sample.pptx") as viewer:
        # Create a PNG image for each slide.
        # {0} is replaced with the current page number in the image name.
        viewOptions = PngViewOptions("render_presentation_to_png/presentation_page_0_{0}.png")
        viewer.view(viewOptions)

if __name__ == "__main__":
    render_presentation_to_png()

sample.pptx is the sample file used in this example. Click here to download it.

render_presentation_to_png/presentation_page_0_1.png (324 KB)
render_presentation_to_png/presentation_page_0_2.png (67 KB)
render_presentation_to_png/presentation_page_0_3.png (87 KB)
render_presentation_to_png/presentation_page_0_4.png (83 KB)
render_presentation_to_png/presentation_page_0_5.png (96 KB)
render_presentation_to_png/presentation_page_0_6.png (80 KB)

Download full output

Render presentations as JPEG

Create a JpgViewOptions class instance and pass it to the Viewer.view method to convert a presentation file to JPEG. Use the JpgViewOptions.height and JpgViewOptions.width methods to specify the output image size in pixels.

from groupdocs.viewer import Viewer
from groupdocs.viewer.options import JpgViewOptions

def render_presentation_to_jpg():
    # Load presentation
    with Viewer("sample.pptx") as viewer:
        # Create a JPG image for each slide.
        # {0} is replaced with the current page number in the image name.
        viewOptions = JpgViewOptions("render_presentation_to_jpg/presentation_to_jpg_{0}.jpg")
        viewOptions.width = 950
        viewOptions.height = 550
        viewer.view(viewOptions)

if __name__ == "__main__":
    render_presentation_to_jpg()

sample.pptx is the sample file used in this example. Click here to download it.

render_presentation_to_jpg/presentation_to_jpg_1.jpg (60 KB)
render_presentation_to_jpg/presentation_to_jpg_2.jpg (40 KB)
render_presentation_to_jpg/presentation_to_jpg_3.jpg (54 KB)
render_presentation_to_jpg/presentation_to_jpg_4.jpg (54 KB)
render_presentation_to_jpg/presentation_to_jpg_5.jpg (65 KB)
render_presentation_to_jpg/presentation_to_jpg_6.jpg (51 KB)

Download full output

Render hidden slides

If your presentation contains hidden slides, use the ViewOptions.render_hidden_pages method for a target view to display these slides in the output HTML, PDF, or image files.

The following code example uses this option to display hidden slides in the generated PDF file:

from groupdocs.viewer import Viewer
from groupdocs.viewer.options import PdfViewOptions

def render_presentation_with_hidden_slides():
    # Load presentation
    with Viewer("sample.pptx") as viewer:
        viewOptions = PdfViewOptions("render_presentation_with_hidden_slides/presentation_with_hidden_slides.pdf")
        viewOptions.render_hidden_pages = True
        viewer.view(viewOptions)

if __name__ == "__main__":
    render_presentation_with_hidden_slides()

sample.pptx is the sample file used in this example. Click here to download it.

Binary file (PDF, 382 KB)

Download full output

Render comments

Comments are rendered by default: the ViewOptions.render_comments property is True unless you change it. The example below sets it explicitly; set it to False to hide the comments when you convert your presentation to HTML, PDF, PNG, or JPEG format.

from groupdocs.viewer import Viewer
from groupdocs.viewer.options import PdfViewOptions

def render_presentation_with_comments():
    # Load presentation
    with Viewer("with_comments.pptx") as viewer:
        viewOptions = PdfViewOptions("render_presentation_with_comments/presentation_with_comments.pdf")
        viewOptions.render_comments = True
        viewer.view(viewOptions)

if __name__ == "__main__":
    render_presentation_with_comments()

with_comments.pptx is the sample file used in this example. Click here to download it.

Binary file (PDF, 380 KB)

Download full output

Render speaker notes

A presentation file can contain speaker notes that help presenters recall important information during the presentation. Speaker notes appear in the Notes pane below each slide.

Speaker notes in Microsoft PowerPoint

Use the ViewOptions.render_notes method for a target view to display speaker notes in the output HTML, PDF, or image files.

The following code sample renders a presentation with speaker notes to PDF:

from groupdocs.viewer import Viewer
from groupdocs.viewer.options import PdfViewOptions

def render_presentation_with_notes():
    # Load presentation
    with Viewer("sample.pptx") as viewer:
        viewOptions = PdfViewOptions("render_presentation_with_notes/presentation_with_notes.pdf")
        viewOptions.render_notes = True
        viewer.view(viewOptions)

if __name__ == "__main__":
    render_presentation_with_notes()

sample.pptx is the sample file used in this example. Click here to download it.

Binary file (PDF, 377 KB)

Download full output