Cheatsheet

The shortest path from “I want to do X” to working code. Each row names the exact function(s) you import. The snippets below the index expand the most common patterns. For prose context see Recipes; for every export see API reference.

Everything lives under the single @office-kit/pptx entry (or @office-kit/pptx/node for the Node fs helpers). The library is fn-only — no classes — so once you know the function name you know how to import it.

Index

Load / save

TaskFunctions
Load a .pptx (any env) → PresentationDataloadPresentation
Save a PresentationDataUint8ArraysavePresentation
Node convenience: read from / write to diskloadPresentationFile + savePresentationToFile (from @office-kit/pptx/node)
Create an empty package (advanced)createPresentation

Slides

TaskFunctions
Enumerate slidesgetSlides (or getSlideAt(pres, i))
Add a slide on a layoutfindSlideLayout + addSlide
Quick blank / title / content slideaddBlankSlide / addTitleSlide / addContentSlide
Duplicate, move, swap, reverseduplicateSlide + moveSlide + swapSlides + reverseSlides
Remove or sortremoveSlide + sortSlides
Title / hidden flag / layoutsetSlideTitle + setSlideHidden + setSlideLayout
Solid background colorsetSlideBackground (or setSlideBackgroundImage)
Speaker notessetSlideNotes + getSlideNotes
TransitionsetSlideTransition

Placeholders & text

TaskFunctions
Find a placeholder by typefindSlidePlaceholder(slide, 'title')
Bulk-fill placeholderssetSlidePlaceholders(slide, { title, body, ... })
Token replace across deck or slidereplaceTokensInPresentation / replaceTokensInSlide
Free text replacereplaceTextInPresentation / replaceTextInSlide
Set / get a shape’s textsetShapeText + getShapeText
Per-run formatting (bold, size, color)setShapeRunFormat
Per-paragraph alignment / level / bulletsetParagraphAlignment + setParagraphLevel + setParagraphBullet
Bullets across the whole shapesetShapeBullets

Shapes

TaskFunctions
Add a free-form text boxaddSlideTextBox
Add a preset shape (180+ presets)addSlideShape
Add a line / connector / arrowaddSlideLine + setShapeStrokeArrow
Add a pictureaddSlideImage
Solid fill / gradient / pattern / image fillsetShapeFill + setShapeGradientFill + setShapePatternFill + setShapeImageFill
Stroke color / width / dashsetShapeStroke + setShapeStrokeDash
Shadow / glowsetShapeShadow + setShapeGlow
Move / resize / rotate / flipsetShapePosition + setShapeSize + setShapeRotation + setShapeFlip
Z-orderbringShapeToFront + sendShapeToBack + bringShapeForward + sendShapeBackward
Hyperlink / click actionsetShapeHyperlink + setShapeClickAction
Animation (entrance / exit)setShapeAnimation({ effect: 'fadeIn', durationMs: 700 })
Remove a shaperemoveShape

Tables

TaskFunctions
Add a tableaddSlideTable
Get / set a cell’s textgetTableCellText + setTableCellText
Cell fill / alignment / text formatsetTableCellFill + setTableCellAlignment + setTableCellTextFormat
Insert / remove a row or columninsertTableRow + removeTableRow + insertTableColumn + removeTableColumn
Resize a row or columnsetTableRowHeight + setTableColumnWidth

Charts

TaskFunctions
Add a chart with embedded dataaddSlideChart({ spec: { kind, categories, series } })
Update an existing chart’s datagetShapeChartSpec + setChartSpec
Enumerate every chartgetAllCharts

Images

TaskFunctions
Replace an image’s bytessetShapeImage
Crop / opacity / brightness / contrastsetShapeImageCrop + setShapeImageOpacity + setShapeImageBrightness + setShapeImageContrast

Document metadata

TaskFunctions
Title / Author / Subject / KeywordssetCoreProperties
App / Company / ManagersetExtendedProperties
Thumbnail imagesetThumbnail
Bump revision on saveincrementRevision + touchModified

Comments

TaskFunctions
Add / remove a commentaddSlideComment + removeSlideComment
List commentsgetSlideComments (or getAllComments)

Diagnostics

TaskFunctions
Validate the packagevalidatePresentation(pres)
Inspect parts listlistPackageParts + readPackagePart
Strip unused mediacompactPackage

Snippets

Each snippet below corresponds to one row above. Imports are explicit so you can copy-paste a single block into your file.

Load + save round-trip

import { loadPresentation, savePresentation } from '@office-kit/pptx';

const pres = await loadPresentation(bytes);
// ...mutate pres...
const out = await savePresentation(pres);

Token-based template fill

import { loadPresentation, replaceTokensInPresentation, savePresentation } from '@office-kit/pptx';

const pres = await loadPresentation(templateBytes);
replaceTokensInPresentation(pres, { name: 'Alice', date: '2026-12-01' });
const out = await savePresentation(pres);

Add a title slide

import {
  addSlide,
  findSlideLayout,
  findSlidePlaceholder,
  loadPresentation,
  savePresentation,
  setShapeText,
} from '@office-kit/pptx';

const pres = await loadPresentation(blankBytes);
const layout = findSlideLayout(pres, 'Title Slide');
if (layout) {
  const slide = addSlide(pres, { layout });
  const t = findSlidePlaceholder(slide, 'ctrTitle') ?? findSlidePlaceholder(slide, 'title');
  if (t) setShapeText(t, 'Hello');
}
const out = await savePresentation(pres);

Add a free-form text box with formatting

import {
  addSlideTextBox,
  inches,
  setShapeRunFormat,
} from '@office-kit/pptx';

const box = addSlideTextBox(slide, {
  x: inches(1),
  y: inches(1),
  w: inches(5),
  h: inches(1),
  text: 'Hello, @office-kit/pptx',
});
setShapeRunFormat(box, 0, 0, { bold: true, size: 28, color: '#C00000', font: 'Calibri' });

Add a preset shape with a fill + shadow

import {
  addSlideShape,
  inches,
  pt,
  setShapeFill,
  setShapeShadow,
} from '@office-kit/pptx';

const star = addSlideShape(slide, {
  preset: 'star5',
  x: inches(1),
  y: inches(2),
  w: inches(2),
  h: inches(2),
  text: '★',
});
setShapeFill(star, '#FFD966');
setShapeShadow(star, {
  blurEmu: pt(6),
  offsetEmu: pt(3),
  angleDeg: 45,
  color: '#000000',
  opacity: 0.4,
});

Add a column chart

import { addSlideChart, inches } from '@office-kit/pptx';

addSlideChart(slide, {
  x: inches(1),
  y: inches(1.5),
  w: inches(8),
  h: inches(4.5),
  spec: {
    kind: 'column',
    categories: ['Q1', 'Q2', 'Q3', 'Q4'],
    series: [{ name: 'Revenue', values: [120, 180, 240, 300] }],
    title: 'FY26',
  },
});

Add a table with header + banded rows

import { addSlideTable, inches } from '@office-kit/pptx';

addSlideTable(slide, {
  x: inches(0.7),
  y: inches(1.5),
  w: inches(9),
  h: inches(3),
  rows: [
    ['Quarter', 'Revenue', 'Margin'],
    ['Q1', '$1.2M', '33%'],
    ['Q2', '$1.8M', '50%'],
  ],
  firstRow: true,
  bandRow: true,
});

Insert an image at a fixed size

import { addSlideImage, inches } from '@office-kit/pptx';

addSlideImage(slide, pngBytes, {
  x: inches(1),
  y: inches(1),
  w: inches(3),
  h: inches(2),
});

Replace an image’s bytes in place

import { getShapeKind, getShapeName, getSlideShapes, getSlides, setShapeImage } from '@office-kit/pptx';

for (const slide of getSlides(pres)) {
  for (const shape of getSlideShapes(slide)) {
    if (getShapeKind(shape) === 'picture' && getShapeName(shape) === 'Logo') {
      setShapeImage(shape, newLogoBytes);
    }
  }
}

Add a hyperlink on text

import { setShapeHyperlink, setShapeTextFormat } from '@office-kit/pptx';

setShapeHyperlink(linkShape, 'https://example.com');
setShapeTextFormat(linkShape, { color: '#0563C1', underline: true });

Set a transition + animation

import { setShapeAnimation, setSlideTransition } from '@office-kit/pptx';

setSlideTransition(slide, { effect: 'fade', speed: 'med' });
setShapeAnimation(shape, { effect: 'fadeIn', durationMs: 700 });

Validate before saving

import { validatePresentation } from '@office-kit/pptx';

const issues = validatePresentation(pres);
for (const i of issues) console.error(i.severity, i.message);

Speaker notes

import { setSlideNotes } from '@office-kit/pptx';

setSlideNotes(slide, 'Open the comments pane to see review.');

Comments

import { addSlideComment, cm } from '@office-kit/pptx';

addSlideComment(slide, {
  author: { name: 'Reviewer', initials: 'R' },
  text: 'Tighten the headline.',
  position: { x: cm(2), y: cm(2) },
});