Add Slide

IronPPT is a powerful library that allows you to automate PowerPoint creation. When it comes to adding slides programmatically, IronPPT has you covered, whether it's adding multiple slides or adding text elements onto them. IronPPT allows you to fully customize and add slides, then add text and other components with an intuitive method, all within one library.

In this example, we'll go through how to add a slide and add text to it as an example of what developers can add.

5-Step Code to Add Slides

  • var document = new PresentationDocument();
  • document.AddSlide();
  • Slide slide = new Slide();
  • slide.AddText("Hello!");
  • document.AddSlide(slide);

Code Explanation

Let's first import the IronPPT library and instantiate a new PresentationDocument, assigning it to a variable. This new PresentationDocument will be an empty PowerPoint presentation to which we will add slides.

Adding an Empty Slide

Adding an empty slide to PowerPoint is as simple as calling AddSlide.

Adding a Slide with Text

In addition to adding an empty slide, we can also create a slide with various elements on it. In this example, we demonstrate adding text to the slide before adding it to the PresentationDocument. We first instantiate a new Slide object, then use the method AddText to add the text "Hello" onto it. Then, afterwards, we use the same AddSlide method as above, but provide the Slide to the AddSlide method to add onto it.

Finally, we save the edited PowerPoint presentation with Save.

Click here to view the How-to Guide, including examples, sample code, and files