PPTX
Slide Layout
Configure slide size, background, and speaker notes
Control the dimensions, background, and notes for each slide.
Slide Dimensions
Set slide size using the size property in the presentation options:
{
"size": { "width": "33.9cm", "height": "19.1cm" },
"slides": [
{
"children": [
{
"shape": {
"x": "2.6cm",
"y": "2.6cm",
"width": "21.2cm",
"height": "10.6cm",
"textBody": { "text": "Widescreen content" }
}
}
]
}
]
}
import { generatePresentation } from "@office-open/pptx";
generatePresentation({
size: { width: "33.9cm", height: "19.1cm" }, // Custom size in EMU or UniversalMeasure
slides: [
{
children: [
{
shape: {
x: "2.6cm",
y: "2.6cm",
width: "21.2cm",
height: "10.6cm",
textBody: { text: "Widescreen content" },
},
},
],
},
],
});
Size Presets
Use string shortcuts for common aspect ratios:
import { generatePresentation } from "@office-open/pptx";
generatePresentation({
size: "16:9", // or "4:3"
slides: [],
});
| Preset | Dimensions (EMU) | Pixels (96 DPI) |
|---|---|---|
"16:9" | 12192000 x 6858000 | 1280 x 720 |
"4:3" | 9144000 x 6858000 | 960 x 720 |
Hidden Slides
Exclude a slide from the slide show with hidden: true (emits p:sld/@show="0"):
import { generatePresentation } from "@office-open/pptx";
generatePresentation({
slides: [
{ children: [], hidden: true }, // skipped during presentation
{ children: [] },
],
});
Slide Background
Solid Color
{
"slides": [
{
"children": [],
"background": { "fill": "1F4E79" }
}
]
}
import { generatePresentation } from "@office-open/pptx";
generatePresentation({
slides: [
{
background: { fill: "1F4E79" },
children: [],
},
],
});
Gradient
{
"slides": [
{
"children": [],
"background": {
"fill": {
"type": "gradient",
"stops": [
{ "position": 0, "color": "0D47A1" },
{ "position": 100, "color": "1976D2" }
],
"angle": 90
}
}
}
]
}
import { generatePresentation } from "@office-open/pptx";
generatePresentation({
slides: [
{
background: {
fill: {
type: "gradient",
stops: [
{ position: 0, color: "0D47A1" },
{ position: 100, color: "1976D2" },
],
angle: 90,
},
},
children: [],
},
],
});
Image Background
import * as fs from "node:fs";
import { generatePresentation } from "@office-open/pptx";
generatePresentation({
slides: [
{
background: {
fill: {
type: "blip",
data: new Uint8Array(fs.readFileSync("bg.png")),
imageType: "png",
},
},
children: [],
},
],
});
Speaker Notes
Add notes visible in presenter mode:
{
"slides": [
{
"children": [
{
"shape": {
"x": "2.6cm",
"y": "2.6cm",
"width": "21.2cm",
"height": "10.6cm",
"textBody": { "text": "Slide content" }
}
}
],
"notes": "Remember to emphasize the key metrics in this slide."
}
]
}
import { generatePresentation } from "@office-open/pptx";
generatePresentation({
slides: [
{
children: [
{
shape: {
x: "2.6cm",
y: "2.6cm",
width: "21.2cm",
height: "10.6cm",
textBody: { text: "Slide content" },
},
},
],
notes: "Remember to emphasize the key metrics in this slide.",
},
],
});
Presentation Metadata
import { generatePresentation } from "@office-open/pptx";
generatePresentation({
title: "Annual Report 2025",
creator: "John Doe",
description: "Yearly financial summary",
subject: "Finance",
keywords: "annual, report, finance",
lastModifiedBy: "Jane Doe",
revision: 1,
slides: [],
});
Metadata Properties
| Property | Type | Description |
|---|---|---|
title | string | Document title |
creator | string | Author name |
description | string | Document description |
subject | string | Subject |
keywords | string | Keywords |
lastModifiedBy | string | Last modifier name |
revision | number | Revision number |
Slide Master
Define slide masters using the masters property. Each master can customize its theme, background, and placeholder layout:
import { generatePresentation } from "@office-open/pptx";
generatePresentation({
masters: [
{
name: "light",
background: { fill: "FFFFFF" },
theme: {
name: "Light Theme",
colors: { dark1: "333333", light1: "FFFFFF" },
},
},
],
slides: [{ children: [] }],
});
Master Children
Add decorative shapes to a master using the children property:
import { generatePresentation } from "@office-open/pptx";
generatePresentation({
masters: [
{
name: "branded",
children: [
{
shape: {
x: "0.0cm",
y: "16.9cm",
width: "25.4cm",
height: "1.1cm",
fill: "4472C4",
},
},
],
},
],
slides: [],
});
Master Placeholders
Control which placeholders appear on the master and their positions:
import { generatePresentation } from "@office-open/pptx";
generatePresentation({
masters: [
{
name: "custom",
placeholders: {
title: { x: "1.3cm", y: "0.5cm", width: "22.8cm", height: "2.1cm" },
body: { x: "1.3cm", y: "3.2cm", width: "22.8cm", height: "13.2cm" },
date: false, // hide date
footer: false, // hide footer
slideNumber: true, // use default position
},
},
],
slides: [],
});
Multiple Masters
Define multiple masters and reference them from slides:
import { generatePresentation } from "@office-open/pptx";
generatePresentation({
masters: [
{
name: "light",
theme: { name: "Light", colors: { dark1: "333333" } },
},
{
name: "dark",
background: { fill: "1B2A4A" },
theme: { name: "Dark", colors: { dark1: "FFFFFF", light1: "1B2A4A" } },
},
],
slides: [
{ master: "light", children: [] },
{ master: "dark", children: [] },
],
});
Slide Layout
Specify a slide's layout type using the layout property:
import { generatePresentation } from "@office-open/pptx";
generatePresentation({
slides: [
{
layout: "title", // or "blank", "obj", "secHead", etc.
children: [],
},
],
});
Layout Types
| Type | Display Name |
|---|---|
"blank" | Blank |
"title" | Title Slide |
"obj" | Title and Content |
"secHead" | Section Header |
"twoObj" | Two Content |
"twoTxTwoObj" | Comparison |
"titleOnly" | Title Only |
"objTx" | Content with Caption |
"picTx" | Picture with Caption |
"vertTx" | Vertical Text |
"vertTitleAndTx" | Vertical Title and Text |
"tx" | Title and Text |
"twoColTx" | Two Content |
"chart" | Content with Caption |
"tbl" | Content with Caption |
Theme Options
Customize theme colors and fonts for each master:
Color Scheme
| Property | Description |
|---|---|
dark1 | Dark primary |
light1 | Light primary |
dark2 | Dark secondary |
light2 | Light secondary |
accent1–accent6 | Accent colors |
hyperlink | Hyperlink color |
followedHyperlink | Visited link color |
Font Scheme
| Property | Description |
|---|---|
majorFont | Heading font (Latin) |
minorFont | Body font (Latin) |
majorFontAsian | Heading font (East Asian) |
minorFontAsian | Body font (East Asian) |