Convert PowerPoint Presentations to Markdown in Python

Convert Presentations to Markdown

The example below shows the simplest way to convert a PowerPoint presentation to Markdown using Aspose.Slides for Python via .NET with default settings.

  1. Instantiate a Presentation to load the presentation.
  2. Call save to export it as a Markdown file.

Use the Python snippet below to perform the conversion:

import aspose.slides as slides

with slides.Presentation("presentation.pptx") as presentation:  
    presentation.save("presentation.md", slides.export.SaveFormat.MD)

Convert Presentations to Markdown Flavor

Aspose.Slides allows you to convert presentations to Markdown formats, including basic Markdown, CommonMark, GitHub-flavored Markdown, Trello, XWiki, GitLab, and 17 other Markdown flavors.

The following Python example shows how to convert a PowerPoint presentation to CommonMark:

import aspose.slides as slides

save_options = slides.export.MarkdownSaveOptions()
save_options.flavor = slides.export.Flavor.COMMON_MARK

with slides.Presentation("presentation.pptx") as presentation:
    presentation.save("presentation.md", slides.export.SaveFormat.MD, save_options)

The 23 supported Markdown flavors are listed in the Flavor enumeration of the MarkdownSaveOptions class.

Convert Presentations Containing Images to Markdown

The MarkdownSaveOptions class provides properties and enumerations that let you configure the resulting Markdown file. For example, the MarkdownExportType enum controls how images are handled: SEQUENTIAL, TEXT_ONLY, or VISUAL.

Convert Images Sequentially

If you want images to appear individually—one after another—in the generated Markdown, choose the SEQUENTIAL option. The Python example below shows how to convert a presentation with images to Markdown.

import aspose.slides as slides

save_options = slides.export.MarkdownSaveOptions()
save_options.show_hidden_slides = True
save_options.show_slide_number = True
save_options.flavor = slides.export.Flavor.GITHUB
save_options.export_type = slides.export.MarkdownExportType.SEQUENTIAL
save_options.new_line_type = slides.export.NewLineType.WINDOWS

slide_indices = [1, 3, 5]

with slides.Presentation("presentation.pptx") as presentation:
    presentation.save("presentation.md", slide_indices, slides.export.SaveFormat.MD, save_options)

Convert Images Visually

If you want the images to appear together in the resulting Markdown, choose the VISUAL option. In this mode, images are saved to the application’s current directory (and the Markdown document uses relative paths), or you can specify a custom output path and folder name.

The Python example below demonstrates this operation:

import os
import aspose.slides as slides

save_options = slides.export.MarkdownSaveOptions()
save_options.export_type = slides.export.MarkdownExportType.VISUAL
save_options.images_save_folder_name = "md-images"
save_options.base_path = "c:\\documents"

with slides.Presentation("presentation.pptx") as presentation:
    file_path = os.path.join(save_options.base_path, "presentation.md")
    presentation.save(file_path, slides.export.SaveFormat.MD, save_options)