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": 12192000, "height": 6858000 },
"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" }, // EMU number 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",
properties: {
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", "object", "sectionHeader", etc.
children: [],
},
],
});
#Layout Types
| Type | Display Name |
|---|---|
"blank" | Blank |
"title" | Title Slide |
"text" | Title and Text |
"twoColumnText" | Two Content |
"titleOnly" | Title Only |
"object" | Title and Content |
"sectionHeader" | Section Header |
"chart" | Chart |
"table" | Table |
"clipArtAndText" | Clip Art and Text |
"pictureText" | Picture with Caption |
"twoObjects" | Two Content |
"twoTextAndTwoObjects" | Comparison |
"objectAndText" | Content with Caption |
"verticalText" | Vertical Text |
"verticalTitleAndText" | Vertical Title and Text |
#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 — FontCollectionOptions (latin, eastAsia, complexScript, symbol) |
minorFont | Body font — FontCollectionOptions (latin, eastAsia, complexScript, symbol) |