PPTX
Quick Start
Create your first PowerPoint presentation in 5 minutes
Get started with @office-open/pptx by creating a simple multi-slide presentation.
Installation
npm install @office-open/pptx
Step 1 — Create a Presentation
import { Presentation, Slide, Shape, Paragraph, TextRun, Packer } from "@office-open/pptx";
const pres = new Presentation({
title: "My First Presentation",
creator: "Author",
slides: [
new Slide({
children: [
new Shape({
x: 1,
y: 1,
width: 8,
height: 1.5,
text: "Hello, PowerPoint!",
paragraphs: [
new Paragraph({
alignment: "center",
children: [
new TextRun({
text: "My First Presentation",
fontSize: 40,
bold: true,
color: "4472C4",
}),
],
}),
],
}),
],
}),
],
});
Step 2 — Add Multiple Slides
import {
Presentation,
Slide,
Shape,
Paragraph,
TextRun,
Picture,
Packer,
convertPixelsToEmu,
} from "@office-open/pptx";
const pres = new Presentation({
slides: [
// Title slide
new Slide({
children: [
new Shape({
x: 1,
y: 2,
width: 8,
height: 2,
text: "Quarterly Report",
paragraphs: [
new Paragraph({
alignment: "center",
children: [
new TextRun({ text: "Q4 2025 Summary", fontSize: 44, bold: true }),
],
}),
new Paragraph({
alignment: "center",
children: [
new TextRun({
text: "Prepared by the Finance Team",
fontSize: 20,
color: "808080",
}),
],
}),
],
}),
],
}),
// Content slide
new Slide({
children: [
new Shape({
x: 0.5,
y: 0.5,
width: 9,
height: 0.8,
text: "Key Highlights",
paragraphs: [
new Paragraph({
children: [
new TextRun({ text: "Key Highlights", fontSize: 28, bold: true }),
],
}),
],
}),
new Shape({
x: 0.5,
y: 1.5,
width: 9,
height: 4,
paragraphs: [
new Paragraph({
bullet: true,
children: [
new TextRun({
text: "Revenue grew by 15% year-over-year",
fontSize: 18,
}),
],
}),
new Paragraph({
bullet: true,
children: [
new TextRun({
text: "Customer satisfaction reached 94%",
fontSize: 18,
}),
],
}),
new Paragraph({
bullet: true,
children: [
new TextRun({ text: "Expanded into 3 new markets", fontSize: 18 }),
],
}),
],
}),
],
}),
],
});
Step 3 — Export the File
Node.js — Write to file
import fs from "node:fs";
const buffer = await Packer.toBuffer(pres);
fs.writeFileSync("presentation.pptx", buffer);
console.log("Created presentation.pptx");
Browser — Download
const blob = await Packer.toBlob(pres);
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "presentation.pptx";
a.click();
URL.revokeObjectURL(url);
Step 4 — Run It
Save the code to a file (e.g., demo.ts) and run:
npx tsx demo.ts