Python PowerPoint API for Presentations
Create, read, modify, and convert PowerPoint and OpenDocument presentations in Python without Microsoft PowerPoint.
Download Free TrialAspose.Slides for Python via Java is a Python library for creating, modifying, rendering, and converting PowerPoint and OpenDocument presentations. It supports slides, shapes, text, charts, tables, images, SmartArt, OLE objects, audio, video, animations, transitions, and VBA macros. The API can also merge, clone, split, compare, and print presentations without Microsoft PowerPoint.
Why Choose Aspose.Slides for Python via Java?
Aspose.Slides for Python via Java offers several advantages for PowerPoint automation:
- Cross-platform compatibility: Use it on Windows, Linux, macOS, and other operating systems.
- Easy integration and deployment: Integrate it with existing applications and deploy it on servers or cloud environments without Microsoft Office.
- Comprehensive presentation processing: Create and modify slides; work with shapes, text, images, animations, transitions, charts, and tables; apply themes and layouts; insert audio and video; and export or print presentations.
- High performance and quality: Process presentations efficiently while preserving output fidelity and accuracy.
- Free trial and licensing options: Download the evaluation version and choose from licensing options such as developer, site, OEM, and cloud licenses.
Advanced Python PowerPoint API Features
Create or clone existing slides from templates
Work with PowerPoint tables via API
Apply or remove shape protection
Add Excel charts as OLE objects to slides
Create shapes and add text to shapes on slides
Handle text and shape formatting
Generate presentations from a database
Protect presentations and generated PDFs
Print presentations on a physical printer
System Requirements
Aspose.Slides for Python via Java can run on Windows, Linux, and macOS when the following software is installed:- JRE 8 or later
- Python 3.7 through 3.12
JPype11.5.0 or later
How to Install
Install Aspose.Slides for Python via Java from its PyPI package page:
pip install aspose-slides-java
How to Create New PowerPoint Presentation in Python
The following example accesses the first slide through a variable, adds a rectangle with addAutoShape, and saves the presentation as PPTX.
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
slide.getShapes().addAutoShape(ShapeType.Rectangle, 50, 150, 300, 200)
presentation.save("presentation.pptx", SaveFormat.Pptx)
finally:
presentation.dispose()
How to Merge Presentations in Python
This example uses addClone to copy every slide from a source presentation to a destination presentation.
destination_presentation = Presentation("presentation1.pptx")
try:
source_presentation = Presentation("presentation2.pptx")
try:
slide_count = source_presentation.getSlides().size()
for slide_index in range(slide_count):
slide = source_presentation.getSlides().get_Item(slide_index)
destination_presentation.getSlides().addClone(slide)
destination_presentation.save("combined-presentation.pptx", SaveFormat.Pptx)
finally:
source_presentation.dispose()
finally:
destination_presentation.dispose()
How to Import a Presentation from PDF in Python
This example removes the default blank slide, calls addFromPdf, and saves the imported pages as a PPTX presentation.
presentation = Presentation()
try:
presentation.getSlides().removeAt(0)
presentation.getSlides().addFromPdf("document.pdf")
presentation.save("presentation.pptx", SaveFormat.Pptx)
finally:
presentation.dispose()
How to Convert PowerPoint to PDF in Python
This example calls save with SaveFormat.Pdf to convert a PowerPoint or OpenDocument presentation to PDF using the default options.
presentation = Presentation("presentation.pptx")
try:
presentation.save("document.pdf", SaveFormat.Pdf)
finally:
presentation.dispose()
How to Convert PowerPoint to JPG in Python
The following example calls getImage for each slide and saves the rendered images with ImageFormat.Jpeg.
presentation = Presentation("presentation.pptx")
try:
slide_count = presentation.getSlides().size()
for slide_index in range(slide_count):
slide = presentation.getSlides().get_Item(slide_index)
slide_image = slide.getImage(2, 2)
try:
file_path = f"slide-{slide_index + 1}.jpg"
slide_image.save(file_path, ImageFormat.Jpeg)
finally:
slide_image.dispose()
finally:
presentation.dispose()
FAQ
- What has to be installed before `pip install aspose-slides-java` will work?A JRE 8 or later, Python 3.7 through 3.12, and
JPype11.5.0 or later. The library talks to a Java runtime through JPype, so the JRE is a hard requirement. - How is this different from Aspose.Slides for Python via .NET?Same capabilities, different bridge. This build calls into Java and needs a JRE; the Python via .NET build carries its own runtime and needs nothing else installed. Choose this one if a JVM is already part of your environment.
- Why do the methods look like `getSlides()` and `get_Item(0)`?Because the API is the Java one surfaced through JPype, so it keeps Java naming. Code written against the Python via .NET build will not run here unchanged.
- Do I need to release the presentation explicitly?Yes. Call
presentation.dispose()in afinallyblock, as the sample on this page does — the underlying Java object is not freed by Python’s garbage collector on its own.
Support and Learning Resources
- Learning Resources
- Documentation
- API References
- Product Support
- Free Support
- Paid Support
- Blog
- Release Notes
- Why Aspose.Slides for Python via Java?
- Customers List
- Success Stories