Skip to content

ReferenceAPI

Presentation

Create, open, render, check and save a deck.

Presentation.md

Create, open, render, check and save a deck. The same text agents read through help().

create(options: { size?: SlideSize; theme?: ThemePresetName | ThemePreset | string } = {}): Presentation

Starts a new deck: Presentation.create() is 16:9 (1280×720 px); also “4:3” or { width, height } in px. theme applies a preset: Presentation.create({ theme: "ledger" }) (see theme.use).

Options: SlideSize, ThemePresetName, ThemePreset.

Presentation.create()
Presentation.create({ theme: "ledger" })
fromTemplate(source: string | Uint8Array, options: { keepSlides?: boolean } = {}): Promise<Presentation>

Starts a deck from a template (a company .potx or any .pptx): its theme, masters and layouts, without its slides unless keepSlides. slides.add({ layout: "Title and Content", title }) then uses the template’s own layouts, by key or by the name PowerPoint shows.

slides.add({ layout: "Title and Content", title })
open(source: string | Uint8Array): Promise<Presentation>

Opens an existing .pptx (or a .potx template) to read, render, check and edit. Saving writes the edits back into a copy of the file: everything you did not change stays as it was. const deck = await Presentation.open("q3.pptx").

const deck = await Presentation.open("q3.pptx")
record(options: { size?: SlideSize } = {}): Recording

A new deck that records every change as a JSON op log: replayable elsewhere with the same anchors (Presentation.resume), undoable step by step, and open to ops sent as JSON. const rec = Presentation.record(); rec.deck.slides.add({ title: "Q3" }); rec.undo();

Options: SlideSize.

const rec = Presentation.record(); rec.deck.slides.add({ title: "Q3" }); rec.undo();
resume(json: OpLogJSON): Recording

Rebuilds a recorded deck from recording.toJSON() and keeps recording.

Options: OpLogJSON.

recording.toJSON()

Who writes comments. Threads themselves are started with slide.comment().

authors: readonly CommentAuthor[]

Everyone who has commented, in order.

items: readonly SlideComment[]

Every thread in the deck, slide by slide.

setAuthor(input: CommentAuthorInput): CommentAuthor

Sets the author of the comments that follow (added once, reused by name): deck.comments.setAuthor({ name: "Ada Byron", userId: "ada@example.com" }).

Options: CommentAuthorInput.

deck.comments.setAuthor({ name: "Ada Byron", userId: "ada@example.com" })
finalize(options: FinalizeOptions): Promise<FinalizeResult>

Checks the real file and publishes it safely: validation, package integrity, the requirements you state, chart data, lint (errors block unless waived) and a re-read of the written file. Never overwrites; writes a receipt and a manifest. await deck.finalize({ output: "out/q3.pptx", requirements: { slideCount: 10, nativeCharts: [slide.id] } })

Options: FinalizeOptions.

await deck.finalize({ output: "out/q3.pptx", requirements: { slideCount: 10, nativeCharts: [slide.id] } })

Footer text, slide numbers and the date across the deck.

set(options: FooterOptions): void

Shows footer text, the slide number and/or a date on every slide (slides can opt out with slide.footer = false).

Options: FooterOptions.

help(query?: string | HelpOptions, options: HelpOptions = {}): string

API help from the generated catalog, sized for a context window: deck.help("slide.charts.add"), deck.help("ShapeOptions.textBox"), deck.help({ search: "gradient" }), or deck.help() for the overview.

Options: HelpOptions.

deck.help("slide.charts.add")
deck.help("ShapeOptions.textBox")
deck.help({ search: "gradient" })
deck.help()
inspect(options: InspectOptions = {}): InspectResult

The deck as bounded NDJSON records with stable anchors: one line per slide, text box, shape, image, table, chart and notes page, with boxes, wrapped line counts and overflow flags. deck.inspect({ kind: "text", slide: 2 }), deck.inspect({ search: "ARR" }), deck.inspect({ target: "sh_X1C8ZP3R", before: 2, after: 2 }).

Options: InspectOptions.

deck.inspect({ kind: "text", slide: 2 })
deck.inspect({ search: "ARR" })
deck.inspect({ target: "sh_X1C8ZP3R", before: 2, after: 2 })
layouts: Layouts

The eleven standard layouts.

lint(options: LintOptions = {}): LintResult

Checks the deck against the v1 rules (overflow, off-canvas, overlap, text size, contrast, placeholders, images, fonts, chart titles, connectors) on the same layout the renderer draws. Errors block finalize(); warnings are worth a look at the render. deck.lint(), deck.lint({ rules: "text/", severity: "error", slide: 3 }).

Options: LintOptions.

deck.lint()
deck.lint({ rules: "text/", severity: "error", slide: 3 })
master: Master

The slide master: background, text styles and decorations shared by every slide.

opened: boolean

True for decks opened from a file (edits are saved back into it).

render(options: RenderOptions & { slides?: number[] } = {}): Promise<Uint8Array[]>

Renders slides to images (all by default), so an agent can look at its work. slides are slide numbers as PowerPoint shows them, from 1: deck.render({ slides: [1, 3] }).

Options: RenderOptions.

deck.render({ slides: [1, 3] })
renderMontage(options: MontageOptions & { slides?: number[] } = {}): Promise<Uint8Array>

Renders slides as one contact-sheet image with slide numbers; slides count from 1.

Options: MontageOptions.

resolve(id: `sl_${string}`): Slide
resolve(id: `th_${string}`): SlideComment
resolve(id: string): Slide | SlideElement | SlideComment

The live object behind an anchor from inspect(): a Slide, or a Shape, Picture, Table, Chart, Connector or Group on a slide, layout or the master. Edit it in place, e.g. (deck.resolve("sh_X1C8ZP3R") as Shape).replaceText("48%", "49%").

(deck.resolve("sh_X1C8ZP3R") as Shape).replaceText("48%", "49%")
save(path: string, options: { manifest?: boolean } = {}): Promise<void>

Writes the deck to a .pptx file. { manifest: true } also writes <path>.manifest.ndjson, the inspect() records, so other tools can read the deck without parsing OOXML.

{ manifest: true }
size: { width: number; height: number }

Slide size in px: { width: 1280, height: 720 } for 16:9.

The slides in order: deck.slides.add({ layout, title, body }), deck.slides.remove(id), deck.slides.move(id, 0).

deck.slides.add({ layout, title, body })
deck.slides.remove(id)
deck.slides.move(id, 0)
[Symbol.iterator](): Iterator<Slide>

for (const slide of deck.slides) works.

for (const slide of deck.slides)
add(options: SlideOptions = {}): Slide

Adds a slide. Pick a layout and fill its placeholders by name: slides.add({ layout: "title-and-content", title: "Q3", body: ["Revenue up 18%", "Costs flat"] }).

Options: SlideOptions.

slides.add({ layout: "title-and-content", title: "Q3", body: ["Revenue up 18%", "Costs flat"] })
at(index: number): Slide | undefined

The slide at a position (negative counts from the end): deck.slides.at(-1).

deck.slides.at(-1)
clear(): void

Deletes every slide, to build the deck again from the start: deck.slides.clear(). The theme, layouts and masters stay. To redo one slide, use slide.clear() instead.

deck.slides.clear()
slide.clear()
duplicate(slide: Slide | string, at?: number): Slide

Copies a slide (with its notes and comments) and puts the copy right after it, or at at: const copy = deck.slides.duplicate("sl_7Q2M4K9A"). The copy’s objects get new ids.

const copy = deck.slides.duplicate("sl_7Q2M4K9A")
filter(fn: (slide: Slide, index: number) => boolean): Slide[]

The slides that pass the test, in order.

find(fn: (slide: Slide, index: number) => boolean): Slide | undefined

The first slide that passes the test.

forEach(fn: (slide: Slide, index: number) => void): void

Like Array.forEach over the slides, in order.

get(slide: string | number): Slide

A slide by anchor id or by position, 0 being first: deck.slides.get("sl_7Q2M4K9A"), deck.slides.get(0). Throws, listing the slides there are, when there is no such slide.

deck.slides.get("sl_7Q2M4K9A")
deck.slides.get(0)
length: number

How many slides the deck has.

map(fn: (slide: Slide, index: number) => T): T[]

Like Array.map over the slides, in order.

move(slide: Slide | string, to: number): void

Moves a slide to a position, 0 being first: deck.slides.move("sl_7Q2M4K9A", 0).

deck.slides.move("sl_7Q2M4K9A", 0)
remove(slide: Slide | string): void

Deletes a slide (by reference or anchor id) with its notes and comments: deck.slides.remove("sl_7Q2M4K9A").

deck.slides.remove("sl_7Q2M4K9A")
theme: Theme

Theme colors and fonts: deck.theme.set({ colors: { accent1: "#2346C8" }, fonts: { heading: "Inter" } }).

deck.theme.set({ colors: { accent1: "#2346C8" }, fonts: { heading: "Inter" } })
toBytes(): Promise<Uint8Array>

Encodes the deck as .pptx bytes using the Artiwright engine.

toProto(): pb.Document

The document model as a protobuf message.