PPTX
Slide Layout
Configure slide size, background, and speaker notes
Control the dimensions, background, and notes for each slide.
Slide Dimensions
Set custom width and height on the Presentation:
import { Presentation, Slide, Shape } from "@office-open/pptx";
const pres = new Presentation({
slideWidth: 13.33, // Width in inches
slideHeight: 7.5, // Height in inches
slides: [
new Slide({
children: [new Shape({ x: 1, y: 1, width: 11, height: 5, text: "Widescreen content" })],
}),
],
});
Slide Size Presets
Use SlideSizePreset for standard dimensions:
import { Presentation, SlideSizePreset } from "@office-open/pptx";
const pres = new Presentation({
slideWidth: SlideSizePreset.WIDESCREEN_16_9, // 13.33 x 7.5 inches
// slideWidth: SlideSizePreset.STANDARD_4_3, // 10 x 7.5 inches
// slideWidth: SlideSizePreset.A3_PORTRAIT, // 11.69 x 16.54 inches
// slideWidth: SlideSizePreset.A4_LANDSCAPE, // 11.69 x 8.27 inches
slides: [],
});
Common Presets
| Preset | Dimensions (inches) | Aspect Ratio |
|---|---|---|
WIDESCREEN_16_9 | 13.33 x 7.5 | 16:9 |
STANDARD_4_3 | 10 x 7.5 | 4:3 |
A3_PORTRAIT | 11.69 x 16.54 | A3 portrait |
A3_LANDSCAPE | 16.54 x 11.69 | A3 landscape |
A4_PORTRAIT | 8.27 x 11.69 | A4 portrait |
A4_LANDSCAPE | 11.69 x 8.27 | A4 landscape |
LETTER_PORTRAIT | 8.5 x 11 | US Letter portrait |
LETTER_LANDSCAPE | 11 x 8.5 | US Letter landscape |
BANNER | 13.33 x 3.75 | Banner |
Slide Background
Solid Color
new Slide({
background: { type: "solid", color: "1F4E79" },
children: [],
});
Gradient
new Slide({
background: {
type: "gradient",
stops: [
{ position: 0, color: "0D47A1" },
{ position: 100, color: "1976D2" },
],
angle: 90,
},
children: [],
});
Image Background
import fs from "node:fs";
new Slide({
background: {
type: "image",
data: fs.readFileSync("bg.png"),
imageType: "png",
},
children: [],
});
Speaker Notes
Add notes that are visible in presenter mode:
new Slide({
children: [new Shape({ x: 1, y: 1, width: 8, height: 5, text: "Slide content" })],
notes: "Remember to emphasize the key metrics in this slide. Pause for questions after showing the chart.",
});
Presentation Metadata
const pres = new Presentation({
title: "Annual Report 2025",
creator: "John Doe",
company: "Acme Inc.",
description: "Yearly financial summary",
subject: "Finance",
keywords: "annual, report, finance",
slides: [],
});
Unit Conversion Helpers
import { convertPixelsToEmu, convertEmuToPixels, percentToTHousandths } from "@office-open/pptx";
convertPixelsToEmu(800); // Pixels to EMU
convertEmuToPixels(914400); // EMU to pixels
percentToTHousandths(75); // 75% → 750000 (thousandths of a percent)