Skip to main content
All docs
V25.2
  • DevExpress Presentation API Library: Create, Load, and Save Presentations

    • 2 minutes to read

    The DevExpress Presentation API library allows you to create a new presentation or load an existing presentation from the following presentation formats:

    • PPTX
    • PPTM
    • POTX
    • POTM

    Create a Presentation

    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();
    

    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.

    Load a Presentation from a Stream

    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));
        }
    

    Note: If you try to load a corrupted presentation file or file in unsupported format, you get a PresentationUnsupportedFormatException.

    Load a Presentation from a Byte Array

    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"));
    

    Note: If you try to load a corrupted presentation file or file in unsupported format, you get a PresentationUnsupportedFormatException.

    Save the Presentation

    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();
    

    To specify the presentation format when saving, use the SaveDocument overload with the corresponding parameter (documentFormat). The default format is PPTX.

    Next Steps

    Configure Slide Masters and Layouts
    Learn how to configure slide masters and layouts.
    Manage Slides
    Learn how to manage slides in a presentation.