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, IDisposableInheritance
IPresentation → Presentation
Constructors
| Signature | Description |
|---|---|
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
| Property | Type | Access | Description |
|---|---|---|---|
Slides | ISlideCollection | Read | Ordered collection of slides in the presentation. |
Masters | IMasterSlideCollection | Read | Collection of master slides. |
LayoutSlides | IGlobalLayoutSlideCollection | Read | Collection of all layout slides across all masters. |
Sections | ISectionCollection | Read | Collection of presentation sections. |
CommentAuthors | ICommentAuthorCollection | Read | Collection of comment authors. |
DocumentProperties | IDocumentProperties | Read | Core, application, and custom document metadata. |
Images | IImageCollection | Read | Collection of all images embedded in the presentation. |
NotesSize | INotesSize | Read | Notes slide size settings. |
SourceFormat | SourceFormat | Read | Format of the loaded presentation source. |
CurrentDateTime | DateTime | Read/Write | Date and time used for date-time placeholders. |
FirstSlideNumber | int | Read/Write | First slide number in the presentation. |
Methods
Save(string, SaveFormat)
Save the presentation to a file.
| Parameter | Type | Description |
|---|---|---|
fname | string | Destination file path. |
format | SaveFormat | Output format (e.g., SaveFormat.Pptx). |
prs.Save("output.pptx", SaveFormat.Pptx);Save(Stream, SaveFormat)
Save the presentation to a stream.
| Parameter | Type | Description |
|---|---|---|
stream | Stream | Destination stream. |
format | SaveFormat | Output format. |
Save(string, int[], SaveFormat)
Save specific slides to a file.
| Parameter | Type | Description |
|---|---|---|
fname | string | Destination file path. |
slides | int[] | Array of 1-based slide indices to include. |
format | SaveFormat | Output format. |
Save(string, SaveFormat, ISaveOptions)
Save the presentation to a file with additional options.
| Parameter | Type | Description |
|---|---|---|
fname | string | Destination file path. |
format | SaveFormat | Output format. |
options | ISaveOptions | Save 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);