Import Presentations with Python

Overview

With Aspose.Slides for Python via .NET, you can import content into a presentation from other file formats. The SlideCollection class provides methods to import slides from PDF, HTML, and other sources.

Convert a PDF to a Presentation

This section shows how to convert a PDF into a presentation using Aspose.Slides. It walks you through importing the PDF, turning its pages into slides, and saving the result as a PPTX file.

pdf-to-powerpoint

  1. Create an instance of the Presentation class.
  2. Call the add_from_pdf method and pass the PDF file.
  3. Use the save method to save the presentation in PowerPoint format.

The following Python example demonstrates converting a PDF to a presentation:

import aspose.slides as slides

with slides.Presentation() as presentation:
    presentation.slides.remove_at(0)

    presentation.slides.add_from_pdf("sample.pdf")

    presentation.save("output.pptx", slides.export.SaveFormat.PPTX)

Convert an HTML to a Presentation

This section shows how to import HTML content into a presentation using Aspose.Slides. It covers loading the HTML, transforming it into slides with preserved text, images, and basic formatting, and saving the result as a PPTX file.

  1. Create an instance of the Presentation class.
  2. Call the add_from_html method and pass the HTML file.
  3. Use the save method to save the presentation in PowerPoint format.

The following Python example demonstrates converting an HTML to a presentation:

import aspose.slides as slides

with slides.Presentation() as presentation:
    presentation.slides.remove_at(0)

    with open("page.html", "rb") as html_stream:
        presentation.slides.add_from_html(html_stream)

    presentation.save("output.pptx", slides.export.SaveFormat.PPTX)