PPTX
批注
为幻灯片添加批注(注释),用于审阅和协作
添加批注
在幻灯片选项中使用 comments 属性添加批注,指定作者、文本和位置:
{
"slides": [
{
"children": [
{
"shape": {
"x": "1.3cm",
"y": "0.8cm",
"width": "13.2cm",
"height": "1.6cm",
"textBody": { "text": "Slide with Comments" },
"fill": "4472C4"
}
}
],
"comments": [
{
"author": "Alice Wang",
"text": "The title looks great!",
"x": "5.3cm",
"y": "1.3cm",
"date": "2026-05-15T10:00:00Z"
},
{
"author": "Bob Li",
"text": "Consider changing the content color.",
"x": "7.9cm",
"y": "4.8cm",
"initials": "BL",
"date": "2026-05-15T11:00:00Z"
}
]
}
]
}
import { generatePresentation } from "@office-open/pptx";
const buffer = await generatePresentation({
slides: [
{
children: [
{
shape: {
x: "1.3cm",
y: "0.8cm",
width: "13.2cm",
height: "1.6cm",
textBody: { text: "Slide with Comments" },
fill: "4472C4",
},
},
],
comments: [
{
author: "Alice Wang",
text: "The title looks great!",
x: "5.3cm",
y: "1.3cm",
date: "2026-05-15T10:00:00Z",
},
{
author: "Bob Li",
text: "Consider changing the content color.",
x: "7.9cm",
y: "4.8cm",
initials: "BL",
date: "2026-05-15T11:00:00Z",
},
],
},
],
});
批注选项
| 属性 | 类型 | 说明 |
| ---------- | -------- | -------------------------------- | ------------------------------------ |
| author | string | 作者显示名称 |
| text | string | 批注文本内容 |
| x | number | UniversalMeasure | 批注标记的水平位置(EMU 或通用度量) |
| y | number | UniversalMeasure | 批注标记的垂直位置(EMU 或通用度量) |
| initials | string | 作者缩写(省略时从姓名自动推导) |
| date | string | ISO 8601 日期字符串 |
作者去重
同一作者在多张幻灯片上添加批注时,系统自动去重——相同作者名只生成一个作者条目,共享统一的缩写和颜色索引。