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.
- Create an instance of the Presentation class.
- Call the add_from_pdf method and pass the PDF file.
- 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)
Tip
You may want to try Aspose’s free PDF to PowerPoint web app—it’s a live implementation of the process described here.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.
- Create an instance of the Presentation class.
- Call the add_from_html method and pass the HTML file.
- 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)
Note
You can also use Aspose.Slides to convert HTML into other popular file formats: