officefileapi-405410-presentation-api-create-load-presentations.md
The DevExpress Presentation API library allows you to create a new presentation or load an existing presentation from the following presentation formats:
Use the Presentation() parameterless constructor to create a new PPTX presentation with one empty slide (the slide’s layout type is SlideLayoutType.Title):
using DevExpress.Docs.Presentation;
//...
Presentation presentation = new Presentation();
Imports DevExpress.Docs.Presentation
'...
Dim presentation As Presentation = New Presentation()
To specify the presentation format, use the Presentation constructor with the corresponding parameter (documentFormat).
A new presentation contains a single default slide master - a layout and appearance settings storage that helps you create consistent slides. For more information, refer to the following section: Layout Presets.
Use the Presentation(Stream) constructor to load a presentation from a stream:
using DevExpress.Docs.Presentation;
//...
using (FileStream fs = File.OpenRead(@"D:\mypresentation.pptx")) {
Presentation presentation = new Presentation(fs);
// Do something with the presentation. For example, export it:
presentation.ExportToPdf(new FileStream(@"D:\exported-document.pdf", FileMode.Create));
}
Imports DevExpress.Docs.Presentation
'...
Using fs As FileStream = File.OpenRead("D:\mypresentation.pptx")
Dim presentation As Presentation = New Presentation(fs)
' Do something with the presentation. For example, export it:
presentation.ExportToPdf(New FileStream("D:\exported-document.pdf", FileMode.Create))
End Using
Note : If you try to load a corrupted presentation file or file in unsupported format, you get a PresentationUnsupportedFormatException.
Use the Presentation(Byte[]) constructor to load a presentation from a byte array:
using DevExpress.Docs.Presentation;
//...
Presentation presentation = new Presentation(File.ReadAllBytes(@"D:\mypresentation.pptx"));
Imports DevExpress.Docs.Presentation
'...
Dim presentation As Presentation = New Presentation(File.ReadAllBytes("D:\mypresentation.pptx"))
Note : If you try to load a corrupted presentation file or file in unsupported format, you get a PresentationUnsupportedFormatException.
Call the SaveDocument method to save the presentation to a file:
FileStream outputStream = new FileStream(@"D:\mypresentation.pptx", FileMode.Create);
presentation.SaveDocument(outputStream);
outputStream.Dispose();
Dim outputStream As FileStream = New FileStream("D:\mypresentation.pptx", FileMode.Create)
presentation.SaveDocument(outputStream)
outputStream.Dispose()
To specify the presentation format when saving, use the SaveDocument overload with the corresponding parameter (documentFormat). The default format is PPTX.
Configure Slide Masters and LayoutsLearn how to configure slide masters and layouts.Manage SlidesLearn how to manage slides in a presentation.