PPTX

Export

Export documents to buffer, blob, base64, or stream

The generatePresentation() function generates a .pptx file from options and returns the result in the requested format. Use generatePresentationSync() for synchronous generation and generatePresentationStream() for streaming.

generatePresentation

Returns a Buffer (default in Node.js). Best for file I/O.

import { generatePresentation } from "@office-open/pptx";
import { writeFileSync } from "node:fs";

// Async (non-blocking)
const buffer = await generatePresentation({
  /* options */
});
writeFileSync("output.pptx", buffer);

Output Types

Control the output format with the second argument:

// Uint8Array (cross-platform)
const bytes = await generatePresentation(opts, { type: "uint8array" });

// Blob (browser)
const blob = await generatePresentation(opts, { type: "blob" });

// Base64 string (API payloads)
const base64 = await generatePresentation(opts, { type: "base64" });

// ArrayBuffer
const ab = await generatePresentation(opts, { type: "arraybuffer" });
typeReturnsUse Case
"nodebuffer"BufferNode.js file I/O
"uint8array"Uint8ArrayCross-platform raw bytes
"blob"BlobBrowser downloads
"base64"stringData URLs, API payloads
"arraybuffer"ArrayBufferMemory handling

Sync Variant

Use generatePresentationSync() for synchronous generation — blocks the main thread but avoids async overhead:

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

const buffer = generatePresentationSync({
  /* options */
});

Streaming

Use generatePresentationStream() for large documents — returns a ReadableStream without buffering the entire file:

import { generatePresentationStream } from "@office-open/pptx";
import { createWriteStream } from "node:fs";
import { Readable } from "node:stream";

const stream = generatePresentationStream({
  /* options */
});
Readable.fromWeb(stream).pipe(createWriteStream("output.pptx"));

Compression Options

All functions accept compression control. Default matches Microsoft Office: XML uses DEFLATE level 1 (SuperFast); media is split by type — already-compressed formats (PNG/JPEG/GIF) use STORE, the rest (EMF/WMF/BMP/TIFF/…) use DEFLATE level 1.

// Default (MS Office)
await generatePresentation(opts);

// Maximum XML compression
await generatePresentation(opts, { compression: { xml: 9 } });

// No compression
await generatePresentation(opts, { compression: { xml: 0 } });
OptionTypeDefaultDescription
compression.xmlnumber1DEFLATE level 0–9
compression.medianumber1compressible media only; PNG/JPEG/GIF always STORE

Browser Download Example

const blob = await generatePresentation(opts, { type: "blob" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "output.pptx";
a.click();
URL.revokeObjectURL(url);
Copyright © 2026