Create Presentation in .NET

Create PowerPoint Presentation

To add a simple plain line to a selected slide of the presentation, please follow the steps below:

  1. Create an instance of Presentation class.
  2. Obtain the reference of a slide by using its Index.
  3. Add an AutoShape of Line type using AddAutoShape method exposed by Shapes object.
  4. Write the modified presentation as a PPTX file.

In the example given below, we have added a line to the first slide of the presentation.

// Instantiate a Presentation object that represents a presentation file
using (Presentation presentation = new Presentation())
{
    // Get the first slide
    ISlide slide = presentation.Slides[0];

    // Add an autoshape of type line
    slide.Shapes.AddAutoShape(ShapeType.Line, 50, 150, 300, 0);
    presentation.Save("NewPresentation_out.pptx", SaveFormat.Pptx);
}

Create and Save Presentation

Steps: Create and Save Presentation in C#

  1. Create an instance of Presentation class.
  2. Save Presentation to any format supported by SaveFormat
Presentation presentation = new Presentation();

presentation.Save("OutputPresenation.pptx", SaveFormat.Pptx);

Open and Save Presentation

Steps: Open and Save Presentation in C#

  1. Create an instance of Presentation class with any format i.e. PPT, PPTX, ODP etc.
  2. Save Presentation to any format supported by SaveFormat
// Load any supported file in Presentation e.g. ppt, pptx, odp etc.
Presentation presentation = new Presentation("Sample.odp");

presentation.Save("OutputPresenation.pptx", SaveFormat.Pptx);