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