Frequently Asked Questions
Frequently Asked Questions
How do I install Aspose.Slides FOSS?
Install from PyPI using pip. Python 3.10 or later is required.
pip install aspose-slides-fossVerify the installation:
import aspose.slides_foss as slides
with slides.Presentation() as prs:
print(f"Slides: {len(prs.slides)}")The lxml dependency is installed automatically. No Microsoft Office or other system runtime is required.
Why must I use with slides.Presentation() as prs:?
The Presentation class manages internal COM-level XML resources. Without the context manager, those resources are not released when the Presentation object goes out of scope, which can cause resource leaks or file locks on Windows.
Always follow this pattern:
with slides.Presentation("input.pptx") as prs:
# work here
prs.save("output.pptx", SaveFormat.PPTX)What file formats can I save to?
Only PPTX is supported:
from aspose.slides_foss.export import SaveFormat
prs.save("output.pptx", SaveFormat.PPTX)Export to PDF, HTML, SVG, or image formats (PNG, JPEG) is not available in this edition.
Can I open .ppt (old PowerPoint 97–2003) files?
No. Only .pptx (Office Open XML) files are supported. Legacy .ppt binary format is not handled by this library.
How do I access slides?
Slides are a zero-based list accessible via prs.slides:
first_slide = prs.slides[0]
slide_count = len(prs.slides)How do I add a second slide?
Use prs.slides.add_empty_slide() with a layout:
with slides.Presentation() as prs:
layout = prs.layout_slides[0]
prs.slides.add_empty_slide(layout)
slide2 = prs.slides[1]
prs.save("two-slides.pptx", SaveFormat.PPTX)How do I set the slide background color?
Access slide.background.fill_format:
from aspose.slides_foss import FillType
from aspose.slides_foss.drawing import Color
slide.background.fill_format.fill_type = FillType.SOLID
slide.background.fill_format.solid_fill_color.color = Color.from_argb(255, 230, 240, 255)How do I use NullableBool?
NullableBool is a tri-state enum used for formatting properties. Use NullableBool.TRUE (not Python’s True) for bold, italic, and similar properties:
from aspose.slides_foss import NullableBool
fmt.font_bold = NullableBool.TRUE
fmt.font_italic = NullableBool.FALSE
fmt.font_underline = NullableBool.NOT_DEFINED # inherits from themeWhy does setting text color have no effect?
You must also set fill_type = FillType.SOLID before assigning the color:
from aspose.slides_foss import FillType
from aspose.slides_foss.drawing import Color
fmt.fill_format.fill_type = FillType.SOLID
fmt.fill_format.solid_fill_color.color = Color.from_argb(255, 200, 0, 0)Can I use charts or SmartArt?
No. Charts, SmartArt, OLE objects, animations, transitions, hyperlinks, VBA macros, and digital signatures are not implemented in this edition and raise NotImplementedError.
Does the library support Python 3.9?
No. Python 3.10 or later is required.
Is this library thread-safe?
Each Presentation object is independent. Creating and using separate Presentation instances from separate threads is safe as long as you do not share a single Presentation object across threads without external locking.
How do I embed an image?
Read the image bytes and add them to prs.images, then create a PictureFrame:
with open("logo.png", "rb") as f:
image_data = f.read()
image = prs.images.add_image(image_data)
slide.shapes.add_picture_frame(slides.ShapeType.RECTANGLE, 50, 50, 200, 150, image)