> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reducto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# .pptx to PNG

## Node

```ts theme={null}
import { writeFile } from "node:fs/promises";
import { PowerPointPresentation } from "@reductoai/pptx/node";

const deck = await PowerPointPresentation.open("input.pptx");
const pages = await deck.toPng({ scale: 2 }); // every slide

for (const { page, png, width, height } of pages) {
  await writeFile(`slide-${page + 1}.png`, png);
  console.log(page, width, height);
}
```

| Option | Default | Notes |
| - | - | - |
| `pages` | every slide | Slide indexes from **0**, for example `[0, 2]` |
| `scale` | `2` | Pixels per CSS pixel. `1` gives 96 dpi (1280 × 720 for a 16:9 deck); `2` gives 192 dpi |
| `includeHiddenSlides` | `false` | Paint hidden slides too |

`png` is the encoded file. The PNG and the PDF come from the same layout, so they agree.

> [!NOTE]
>
> Slides count from 0 here, as `LayoutPage.index` does for a deck. The Word package counts pages from 1.

## One slide or one shape

`getImageAsBase64` gives one slide or one shape as a base64 PNG, as in Office.js:

```ts theme={null}
const slide = deck.slides.getItemAt(0);
const slidePng = await slide.getImageAsBase64({ width: 640 });
const shapePng = await slide.shapes.getItemAt(0).getImageAsBase64();
```

## Thumbnails

For a small preview, paint at a low scale:

```ts theme={null}
const [thumb] = await deck.toPng({ pages: [0], scale: 0.25 });
```
