How to Get Started with Aspose.Slides FOSS for .NET

How to Get Started with Aspose.Slides FOSS for .NET

Aspose.Slides.Foss for .NET is a free, MIT-licensed library for creating and editing PowerPoint .pptx files — no Microsoft Office required, available on NuGet.

Step-by-Step Guide

Step 1: Install the Package

Install from NuGet (.NET 9.0 or later required):

dotnet add package Aspose.Slides.Foss

Verify the install by building the project:

dotnet build

Step 2: Import Required Namespaces

Add the using directives you need for loading presentations and saving:

using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Export;

Step 3: Create a Presentation

Construct a Presentation with no arguments to start with one blank slide. Always use using to ensure internal resources are released:

using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Export;

using var prs = new Presentation();
Console.WriteLine($"Slides: {prs.Slides.Count}");
prs.Save("new_presentation.pptx", SaveFormat.Pptx);

Step 4: Add a Shape with Text

Use slide.Shapes.AddAutoShape() to insert a rectangle, then call AddTextFrame() to add text content:

using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Export;

using var prs = new Presentation();
var slide = prs.Slides[0];
var shape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 50, 400, 150);
var tf = shape.AddTextFrame("Hello from Aspose.Slides FOSS!");
var fmt = tf.Paragraphs[0].Portions[0].PortionFormat;
fmt.FontHeight = 24;
fmt.FontBold = NullableBool.True;
prs.Save("with_shape.pptx", SaveFormat.Pptx);

Step 5: Apply a Fill and Save

Set a solid fill color on the shape before saving:

using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Drawing;
using Aspose.Slides.Foss.Export;

using var prs = new Presentation();
var shape = prs.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 100, 100, 400, 200);
shape.FillFormat.FillType = FillType.Solid;
shape.FillFormat.SolidFillColor.Color = Color.FromArgb(255, 70, 130, 180);
shape.AddTextFrame("Styled shape");
prs.Save("styled.pptx", SaveFormat.Pptx);

Common Issues and Fixes

TypeLoadException or DllNotFoundException Ensure you are targeting .NET 9.0 or later. The library requires .NET 9.0+. Update your .csproj file: <TargetFramework>net9.0</TargetFramework>

UnsupportedOperationException when calling certain methods Some features (charts, animations, PDF export) are not supported in this release. Check the API reference for a list of limitations before using advanced features.

ObjectDisposedException after the using block Do not use a Presentation instance outside its using block. Access all slides, shapes, and text frames before the using block exits.

File not saved correctly Always pass a SaveFormat enum value to Save(). The overload Save(path, SaveFormat.Pptx) writes a PPTX-format file.

Frequently Asked Questions

Does Aspose.Slides.Foss require Microsoft Office?

No. The library creates and reads .pptx files natively in pure C# with no dependency on Microsoft Office, COM automation, or Windows APIs.

Which .NET versions are supported?

.NET 9.0 or later. The library runs on Windows, macOS, Linux, and Docker containers.

Is the library free for commercial use?

Yes. It is released under the MIT License. You may use, modify, and redistribute it for any purpose, including commercial applications.

Can I load an existing PPTX file?

Yes. Pass the file path to the Presentation constructor:

using var prs = new Presentation("existing.pptx");
Console.WriteLine($"Loaded {prs.Slides.Count} slides");
prs.Save("copy.pptx", SaveFormat.Pptx);

Do I need to call Dispose explicitly?

Yes, via the using statement. Presentation implements IDisposable and must be disposed to release file handles and internal resources.

See Also

 English