PPTX
补丁修改
通过 PresentationOptions canonical 命令修改现有 .pptx
patchPresentation 先把 .pptx 解析成 PresentationOptions,再按顺序执行命令并重新生成包。未编辑的 canonical 字段会保留来源 round-trip 信息。
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" },
],
});
幻灯片路由支持 index、id 和 name;嵌套路由可以定位 children、comments、版式、母版和其他 canonical 集合。宏文档和模板文档需要设置 packageVariant。
#选项
| 选项 | 类型 | 默认值 |
|---|---|---|
data | DataType | 必填 |
commands | readonly PresentationPatchCommand[] | 必填 |
outputType | OutputType | "uint8array" |
packageVariant | "standard" | "macro" | "template" | "macroTemplate" | "standard" |
placeholderDelimiters | { start, end } | { start: "{{", end: "}}" } |