---
title: "Create a PowerPoint presentation in C#"
url: https://recursiveai.org/onedocument/cookbook/create-powerpoint-presentation/
description: "Create a PowerPoint PPTX from scratch in C# with two built-in slide layouts. Fill title and content placeholders and reopen the saved deck."
version: "1.0.0"
---

```shell
dotnet add package RecursiveAI.OneDocument.Presentations
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using RecursiveAI.OneDocument.Presentations;
using var deck = Presentation.Create();
var slide = deck.AddSlide("Title and Content");
slide.SetPlaceholderText("title", "Regions");
slide.SetPlaceholderText(1, "North grew");
deck.SaveAs("review.pptx");
```

Unzip [the example](https://recursiveai.org/onedocument/cookbook/create-powerpoint-presentation/create-powerpoint-presentation.zip), then `dotnet run`.

Writes `review.pptx` with one slide titled “Regions”; it prints nothing. You don’t need a template or a PowerPoint installation.

## The full program

The download saves a two-slide deck, reopens it, and prints the slide count and text. All the input is in `Program.cs`.

```csharp
using RecursiveAI.OneDocument.Presentations;

using var deck = Presentation.Create();
var title = deck.AddSlide("Title Slide");
title.SetPlaceholderText("title", "Quarterly review");
title.SetPlaceholderText("subTitle", "Half-year results");
var content = deck.AddSlide("Title and Content");
content.SetPlaceholderText("title", "Regions");
content.SetPlaceholderText(1, "North grew\nSouth held");
deck.SaveAs("review.pptx");

using var saved = Presentation.Open("review.pptx");
Console.WriteLine($"Slides: {saved.Slides.Count}");
foreach (var slide in saved.Slides)
{
    foreach (var shape in slide.Shapes)
        if (!string.IsNullOrEmpty(shape.Text))
            Console.WriteLine(shape.Text);
}
```

```text
Slides: 2
Quarterly review
Half-year results
Regions
North grew
South held
```

An unknown layout name or a missing placeholder throws `PresentationAuthoringException`; the two layouts in this example come with `Presentation.Create()`.

## Variations

To make the second slide the first, pass its insertion index when you add it. Replace the `AddSlide` call for `content` in the full program:

```csharp
var content = deck.AddSlide("Title and Content", 0);
```

The resulting deck starts with “Regions”, followed by “Quarterly review”.

## Related recipes

- [Fill a PowerPoint template](https://recursiveai.org/onedocument/cookbook/fill-powerpoint-template/)
- [Edit PowerPoint speaker notes](https://recursiveai.org/onedocument/cookbook/edit-powerpoint-speaker-notes/)
- [Convert a PowerPoint presentation to PDF](https://recursiveai.org/onedocument/cookbook/convert-pptx-to-pdf/)

## The short answer

Call `Presentation.Create()`, add slides by layout name, set their placeholder text, and save to a `.pptx` path. OneDocument supplies the layouts and writes the file itself; no PowerPoint process or input file is needed.

## How do I create PowerPoint slides programmatically in C#?

Choose a layout for each slide. “Title Slide” gives the cover a title and a subtitle. “Title and Content” gives the second slide a title and a space for the update. `AddSlide` appends by default, so create the slides in the order you want the audience to see them. The insertion-index variation is useful when you already have slides and need to put one ahead of them.

`SaveAs` writes the presentation, not a PDF or an image of each slide. The text remains editable. Open `review.pptx` from the directory where you ran the project to see how the two layouts position it. The console output in the download checks the content that was saved; it doesn’t show the appearance or whether a long paragraph fits on the slide.

## How do PowerPoint slide layouts and placeholders work?

A placeholder is a shape whose role is set by the layout, such as a title or an area for content. OneDocument uses the layout to create the slide’s placeholders. The [presentation model](https://recursiveai.org/onedocument/docs/presentations/#inheritance) describes where their styling and bounds come from: the slide can inherit them from its layout and master. That’s why the snippet can set the text without specifying a font size or any coordinates.

Select a text placeholder by type when its role identifies it: `"title"` for the title (including a centered title), or `"subTitle"` for the subtitle. The number `1` in the second slide is the placeholder’s layout index, not the slide number or the position of a shape in a list. On the built-in “Title and Content” layout that index identifies the content placeholder. If you change the layout, check its placeholders rather than assuming the index means the same thing.

## Can I create a PowerPoint presentation from scratch without a template?

Yes. The built-in layouts let you create a new deck from text supplied by your application. Start there when you want the program to decide the number, order and content of the slides. If you already have a designed deck with slide backgrounds, branding or placeholders positioned by a designer, start with that file instead. Filling an existing template preserves the starting design rather than asking your code to recreate it.
