---
title: "Export a single PowerPoint slide to PNG in C#"
url: https://recursiveai.org/onedocument/cookbook/render-powerpoint-slide-as-png/
description: "Export one slide from a PowerPoint PPTX to PNG in C# without converting the whole deck. Choose a slide by index and save the image at 144 dpi."
version: "1.0.0"
---

Save one slide as an image for a preview without converting the deck to PDF.

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

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 RecursiveAI.OneDocument.Rendering
    .Presentations;

// review.pptx is in the download.
using var deck =
    Presentation.Open("review.pptx");
var png =
    PresentationRenderer.RenderPng(deck, 1);
File.WriteAllBytes("regions.png", png);
Console.WriteLine("Wrote regions.png");
```

Unzip [the example](https://recursiveai.org/onedocument/cookbook/render-powerpoint-slide-as-png/render-powerpoint-slide-as-png.zip), then `dotnet run`.

By default, the index is zero-based and counts only visible slides, so `RenderPng(deck, 1)` exports the second visible slide.

Writes `regions.png` from the second visible slide and prints:

```text
Wrote regions.png
```

The included `review.pptx` has two visible slides: “Quarterly review” and “Regions”. The “Regions” slide reads “North grew” and “South held”.

## The full program

The download also reads the width and height from the PNG header, so you can see the dimensions of the exported slide.

```csharp
using RecursiveAI.OneDocument.Presentations;
using RecursiveAI.OneDocument.Rendering.Presentations;
using System.Buffers.Binary;

using var deck = Presentation.Open("review.pptx");
byte[] png = PresentationRenderer.RenderPng(deck, 1);
File.WriteAllBytes("regions.png", png);
int width = BinaryPrimitives.ReadInt32BigEndian(png.AsSpan(16, 4));
int height = BinaryPrimitives.ReadInt32BigEndian(png.AsSpan(20, 4));
Console.WriteLine($"regions.png: {width} × {height} pixels");
```

`dotnet run` prints:

```text
regions.png: 1920 × 1080 pixels
```

If the index is outside the selected output pages, `RenderPng` throws `ArgumentOutOfRangeException` before the example writes a file.

## Variations

**Export the first visible slide.** Replace the lines that assign `png`, write it, and print the filename in the snippet at the top:

```csharp
var png =
    PresentationRenderer.RenderPng(deck, 0);
File.WriteAllBytes("cover.png", png);
Console.WriteLine("Wrote cover.png");
```

```text
Wrote cover.png
```

## Related recipes

- [Create a PowerPoint presentation in C#](https://recursiveai.org/onedocument/cookbook/create-powerpoint-presentation/)
- [Convert PowerPoint to PDF in C#](https://recursiveai.org/onedocument/cookbook/convert-pptx-to-pdf/)

## The short answer

Open the `.pptx`, pass the index of the slide you want to `PresentationRenderer.RenderPng`, and save the returned bytes. The index is zero-based and counts only visible slides by default. The input presentation stays unchanged.

## How do I export a single PPT slide as PNG?

Use `RenderPng` when the requested slide isn’t necessarily the first. Saving the deck to a `.png` path through `SaveAs` writes the first output page; it doesn’t let you select an index. The explicit call takes the index and gives you PNG bytes directly, so you don’t need to copy the slide to a temporary deck or write a PDF first.

By default, index `1` means the second *visible* slide, not necessarily slide 2 in the original presentation. For example, if slide 2 is hidden in a deck with three slides, index `1` renders slide 3. If your input is an original slide number and you want hidden slides to count, set `IncludeHiddenSlides` to `true` in `PresentationRenderOptions` and subtract one from that number. Keep the output mode at its default of `Slides`; notes pages and handouts select different output pages.

## What resolution is a PowerPoint slide exported to PNG?

OneDocument’s `RenderPng` uses 144 dots per inch with no DPI option. Pixel dimensions follow the slide’s page size, with each dimension rounded up to a whole pixel. For a preview with a fixed width, check the actual dimensions as the full program does and resize the image afterward. A deck with a different slide aspect ratio won’t produce the same width and height as this sample.

The PNG shows a static slide, not an animation frame. Animations and transitions are not rendered. If a slide includes SmartArt, the renderer draws the saved diagram drawing if one is present; it doesn’t rebuild a missing drawing from the diagram’s layout. See the [presentation rendering docs](https://recursiveai.org/onedocument/docs/presentation-rendering/) for how slide backgrounds, shapes and pictures are drawn.
