Introduction
Aspose.Slides FOSS for Python (aspose-slides-foss on PyPI) is a free, MIT-licensed
library for creating and editing PowerPoint .pptx files entirely in Python. It runs on
Windows, macOS, Linux, and Docker containers with no dependency on Microsoft Office.
This article walks through the key features available in version 26.3.2.
Key Features
Presentation Loading and Saving
Presentation is the root object. Construct it with no arguments to create a new file
or pass a file path to load an existing one. Call save() with a SaveFormat to write
the output:
from aspose.slides_foss import Presentation
from aspose.slides_foss.export import SaveFormat
# Create new
prs = Presentation()
prs.save("output.pptx", SaveFormat.PPTX)
# Load and save
prs2 = Presentation("existing.pptx")
prs2.save("copy.pptx", SaveFormat.PPTX)
Slide Management
The slides property returns a SlideCollection. Add slides with add_empty_slide(),
remove them with remove(), and access existing slides by index:
from aspose.slides_foss import Presentation
from aspose.slides_foss.export import SaveFormat
prs = Presentation()
slide = prs.slides[0] # First slide (created automatically)
# Add a second slide using the first master/layout
layout = prs.masters[0].layout_slides[0]
new_slide = prs.slides.add_empty_slide(layout)
prs.save("two_slides.pptx", SaveFormat.PPTX)
AutoShape Insertion and Text
Add shapes using slide.shapes.add_auto_shape(). Capture the returned ITextFrame
from add_text_frame() to set text content:
from aspose.slides_foss import Presentation, ShapeType
from aspose.slides_foss.export import SaveFormat
prs = Presentation()
slide = prs.slides[0]
shape = slide.shapes.add_auto_shape(ShapeType.RECTANGLE, 50, 50, 300, 100)
tf = shape.add_text_frame("Hello from Aspose.Slides FOSS")
tf.paragraphs[0].portions[0].portion_format.font_height = 24
prs.save("shape_demo.pptx", SaveFormat.PPTX)
Solid and Gradient Fills
Apply FillType.SOLID with an ARGB color or FillType.GRADIENT for multi-stop fills:
from aspose.slides_foss import Presentation, ShapeType, FillType
from aspose.slides_foss.drawing import Color
from aspose.slides_foss.export import SaveFormat
prs = Presentation()
slide = prs.slides[0]
shape = slide.shapes.add_auto_shape(ShapeType.RECTANGLE, 100, 100, 400, 200)
shape.fill_format.fill_type = FillType.SOLID
shape.fill_format.solid_fill_color.color = Color.from_argb(255, 70, 130, 180)
prs.save("solid_fill.pptx", SaveFormat.PPTX)
Visual Effects
Apply outer shadows, glow, and soft-edge effects via shape.effect_format:
from aspose.slides_foss import (
Presentation, ShapeType,
FillType, NullableBool
)
from aspose.slides_foss.drawing import Color
from aspose.slides_foss.export import SaveFormat
prs = Presentation()
slide = prs.slides[0]
shape = slide.shapes.add_auto_shape(ShapeType.RECTANGLE, 100, 100, 300, 150)
ef = shape.effect_format
ef.enable_outer_shadow_effect()
ef.outer_shadow_effect.blur_radius = 8
ef.outer_shadow_effect.distance = 6
ef.outer_shadow_effect.direction = 45
ef.outer_shadow_effect.shadow_color.color = Color.from_argb(128, 0, 0, 0)
prs.save("shadow.pptx", SaveFormat.PPTX)
Quick Start
pip install aspose-slides-foss>=26.3.2
from aspose.slides_foss import Presentation, ShapeType
from aspose.slides_foss.export import SaveFormat
prs = Presentation()
slide = prs.slides[0]
shape = slide.shapes.add_auto_shape(ShapeType.RECTANGLE, 50, 50, 400, 150)
shape.add_text_frame("My first slide")
prs.save("first.pptx", SaveFormat.PPTX)
Supported Formats
| Format | Extension | Read | Write |
|---|---|---|---|
| PowerPoint (OOXML) | .pptx | ✓ | ✓ |
Open Source & Licensing
Aspose.Slides FOSS for Python is released under the MIT License. Install from PyPI
as aspose-slides-foss. Commercial use, redistribution, and modification are all permitted.