PPTX
Patching
Modify an existing .pptx through canonical PresentationOptions commands
patchPresentation parses an existing .pptx into PresentationOptions, applies ordered commands, and regenerates the package. Unedited canonical fields retain source round-trip facts.
import { patchPresentation } from "@office-open/pptx";
const result = await patchPresentation({
data: deck,
commands: [
{
type: "replace",
at: { field: "slides", route: [{ index: 0 }], text: { placeholder: "title" } },
value: "Quarterly Review",
},
{
type: "insert",
at: { field: "slides" },
position: "end",
value: [{ children: [{ shape: { x: 0, y: 0, width: "10cm", height: "2cm" } }] }],
},
{ type: "remove", at: { field: "slides", route: [{ index: 1 }] } },
{ type: "update", at: { field: "title" }, set: "Board Deck" },
],
});
Slide routes accept an index, slide id, or slide name. Nested routes can address children, comments, layouts, masters, and other canonical collections. Set packageVariant for macro and template decks.
#Options
| Option | Type | Default |
|---|---|---|
data | DataType | required |
commands | readonly PresentationPatchCommand[] | required |
outputType | OutputType | "uint8array" |
packageVariant | "standard" | "macro" | "template" | "macroTemplate" | "standard" |
placeholderDelimiters | { start, end } | { start: "{{", end: "}}" } |