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);

批注选项

属性类型说明
authorstring作者显示名称
textstring批注文本内容
xnumber批注标记的水平位置(像素)
ynumber批注标记的垂直位置(像素)
initialsstring作者缩写(省略时从姓名自动推导)
datestringISO 8601 日期字符串

作者去重

同一作者在多张幻灯片上添加批注时,系统自动去重——相同作者名只生成一个作者条目,共享统一的缩写和颜色索引。

Copyright © 2026