PPTX

@office-open/pptx

Generate .pptx presentations with a declarative TypeScript API

Installation

pnpm add @office-open/pptx

Quick Start

import {
    Presentation,
    Packer,
    Slide,
    Shape,
    TextBody,
    Paragraph,
    TextRun,
} from "@office-open/pptx";

const presentation = new Presentation({
    slides: [
        new Slide({
            children: [
                new Shape({
                    body: new TextBody({
                        children: [
                            new Paragraph({
                                children: [new TextRun("Hello World")],
                            }),
                        ],
                    }),
                }),
            ],
        }),
    ],
});

const buffer = await Packer.toBuffer(presentation);

Main Components

ComponentDescription
PresentationRoot presentation container with slides and properties
SlideA single slide with shapes, media, and layout
ShapeRectangle, rounded rectangle, and custom geometry shapes
GroupShapeGrouped shapes with collective transform
TextBody, Paragraph, TextRunRich text content inside shapes
Table, TableRow, TableCellTables with merged cells and styling
PictureEmbedded images on slides
ChartFrameBar, line, pie, area, and scatter charts
SmartArtFramePredefined SmartArt diagrams
VideoFrame, AudioFrameEmbedded video and audio
LineShape, ConnectorShapeLines and connectors between elements
TransitionSlide transition effects
AnimationShape entrance, emphasis, and exit animations
HeaderFooterSlide footers with date, number, and text

Export Formats

MethodReturnsUse Case
Packer.toBuffer(doc)Uint8ArrayNode.js file I/O
Packer.toBlob(doc)BlobBrowser downloads
Packer.toBase64String(doc)stringData URLs, API payloads
Packer.toString(doc)stringDebugging, inspection
Packer.toStream(doc)ReadableStreamStreaming large files

Slide Size Presets

import { SlideSizePreset } from "@office-open/pptx";

const presentation = new Presentation({
    slideSize: SlideSizePreset.WIDESCREEN_16X9,
    slides: [
        // ...
    ],
});

Available presets:

PresetDimensions
WIDE13.33" × 7.5" (widescreen)
STANDARD_4X310" × 7.5" (standard)
WIDESCREEN_16X1010" × 6.25"
WIDESCREEN_16X913.33" × 7.5"
Copyright © 2026