# Saving Presentations

exportToFile, exportToBytes, exportToStream — and several presentations per process.

```csharp
using NetCorePpt;                  // PptxGen, Slide
using NetCorePpt.CoreInterfaces;   // option objects: TextProps* / ShapeProps / ImageProps / TableProps / HAlign / VAlign ...
using NetCorePpt.CoreEnums;        // ShapeType, ChartType, MediaType, ShadowType, BulletType, DashType, SCHEME_COLORS ...
using TableRow = System.Collections.Generic.List<NetCorePpt.CoreInterfaces.TableCell>;
```

Several methods are available when generating a presentation.

- Every export method writes the complete package before it returns
- Runnable samples: see the [Usage Examples](/examples_docs/) section of this site

## Saving as a File (exportToFile)

Write the finished presentation to a `.pptx` file on disk.

### Export Options (exportToFile)

| Argument | Type | Default | Description |
| --- | --- | --- | --- |
| `outputFilepath` | string | — | path of the file to write |
| `compress` | bool | `true` | apply zip compression (smaller file, a little slower) |

### Export File Example

**NetCorePpt · C#**

```csharp
// `exportToFile` is awaited - there is no promise chain to manage
var fileName = await pptx.exportToFile("Presentation-Demo.pptx");
Console.WriteLine($"created file: {fileName}");
```

## Generating Other Formats (exportToBytes)

Keep the presentation in memory as a `byte[]` — useful for uploading to cloud storage, returning it from an API or attaching it to a message. The other output types the JavaScript library offers (`blob`, `arraybuffer`, `nodebuffer`, …) are browser/Node containers; on .NET the bytes cover all of them.

### Export Example

**NetCorePpt · C#**

```csharp
var data = await pptx.exportToBytes();
Console.WriteLine($"presentation is {data.Length} bytes");
Console.WriteLine(Convert.ToBase64String(data, 0, Math.Min(100, data.Length)));

// ...or hand the bytes to whatever needs them:
await File.WriteAllBytesAsync("Presentation-Demo.pptx", data);
```

## Streaming (exportToStream)

Write the package into any `Stream` — an HTTP response body, a file, a blob in the cloud.

**NetCorePpt · C#**

```csharp
// ASP.NET Core: stream it straight into the response
app.MapGet("/presentation", async (HttpContext ctx) =>
{
    ctx.Response.ContentType =
        "application/vnd.openxmlformats-officedocument.presentationml.presentation";
    ctx.Response.Headers.ContentDisposition =
        "attachment; filename=Presentation-Demo.pptx";

    var bytes = await pptx.exportToBytes();
    await ctx.Response.Body.WriteAsync(bytes);
});

// Or into a MemoryStream / FileStream:
using var ms = new MemoryStream();
await ms.WriteAsync(await pptx.exportToBytes());
```

## Creating Multiple Presentations

One `PptxGen` instance is one presentation. Create a new instance for each deck — nothing is shared between them.

**NetCorePpt · C#**

```csharp
// Presentation 1
var pptx1 = new PptxGen();
pptx1.addSlide().addText("Presentation 1", new TextPropsOptions { x = 1, y = 1 });
await pptx1.exportToFile("Presentation-1.pptx");

// Presentation 2
var pptx2 = new PptxGen();
pptx2.addSlide().addText("Presentation 2", new TextPropsOptions { x = 1, y = 1 });
await pptx2.exportToFile("Presentation-2.pptx");
```
