Presentation

Presentation — Aspose.Slides FOSS for .NET API Reference

The Presentation class is the root object for creating, loading, and saving PowerPoint .pptx files in Aspose.Slides FOSS for .NET. It implements IPresentation and IDisposable.

Package: Aspose.Slides.Foss (net9.0)

using Aspose.Slides.Foss;
public class Presentation : IPresentation, IDisposable

Inheritance

IPresentationPresentation


Constructors

SignatureDescription
Presentation()Create a new empty presentation with one blank slide.
Presentation(ILoadOptions loadOptions)Create a new empty presentation with load options.
Presentation(Stream stream)Load a presentation from a stream.
Presentation(Stream stream, ILoadOptions loadOptions)Load a presentation from a stream with load options.
Presentation(string file)Load a presentation from a file path.
Presentation(string file, ILoadOptions loadOptions)Load a presentation from a file path with load options.

Examples:

using Aspose.Slides.Foss;

// Create a new empty presentation
using var prs = new Presentation();

// Open an existing PPTX file
using var prs2 = new Presentation("deck.pptx");

// Load from a stream
using var stream = File.OpenRead("deck.pptx");
using var prs3 = new Presentation(stream);

Properties

PropertyTypeAccessDescription
SlidesISlideCollectionReadOrdered collection of slides in the presentation.
MastersIMasterSlideCollectionReadCollection of master slides.
LayoutSlidesIGlobalLayoutSlideCollectionReadCollection of all layout slides across all masters.
SectionsISectionCollectionReadCollection of presentation sections.
CommentAuthorsICommentAuthorCollectionReadCollection of comment authors.
DocumentPropertiesIDocumentPropertiesReadCore, application, and custom document metadata.
ImagesIImageCollectionReadCollection of all images embedded in the presentation.
NotesSizeINotesSizeReadNotes slide size settings.
SourceFormatSourceFormatReadFormat of the loaded presentation source.
CurrentDateTimeDateTimeRead/WriteDate and time used for date-time placeholders.
FirstSlideNumberintRead/WriteFirst slide number in the presentation.

Methods

Save(string, SaveFormat)

Save the presentation to a file.

ParameterTypeDescription
fnamestringDestination file path.
formatSaveFormatOutput format (e.g., SaveFormat.Pptx).
prs.Save("output.pptx", SaveFormat.Pptx);

Save(Stream, SaveFormat)

Save the presentation to a stream.

ParameterTypeDescription
streamStreamDestination stream.
formatSaveFormatOutput format.

Save(string, int[], SaveFormat)

Save specific slides to a file.

ParameterTypeDescription
fnamestringDestination file path.
slidesint[]Array of 1-based slide indices to include.
formatSaveFormatOutput format.

Save(string, SaveFormat, ISaveOptions)

Save the presentation to a file with additional options.

ParameterTypeDescription
fnamestringDestination file path.
formatSaveFormatOutput format.
optionsISaveOptionsSave options controlling output behavior.

Dispose()

Release resources held by the presentation. Called automatically when using the using statement.


Usage Examples

Create a Presentation with a Shape

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, 300, 100);
shape.AddTextFrame("Hello, Slides!");
prs.Save("hello.pptx", SaveFormat.Pptx);

Open, Inspect, and Re-Save

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

using var prs = new Presentation("existing.pptx");
Console.WriteLine($"Slides: {prs.Slides.Count}");
foreach (var slide in prs.Slides)
{
    Console.WriteLine($"  Slide: {slide.Shapes.Count} shapes");
}
prs.Save("existing-updated.pptx", SaveFormat.Pptx);

Set Document Properties

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

using var prs = new Presentation();
prs.DocumentProperties.Title = "Q1 Results";
prs.DocumentProperties.Author = "Finance Team";
prs.DocumentProperties.Subject = "Quarterly Review";
prs.Save("q1.pptx", SaveFormat.Pptx);

See Also