如何在Google Antigravity中使用IronPPT

Curtis Chau
Curtis Chau
更新: 2026年10月19日

项目管理办公室每周一发布每个项目的状态文档。 在StatusDesk,办公室的网页应用中,项目经理点击项目行上的下载状态文档,获取服务器稍早构建的PowerPoint文件。 文档下载时可以没有错误,却可能打开后首张幻灯片为空,文本框叠加或者是另一个项目的幻灯片。 这些错误都不会出现在构建日志中。

Google Antigravity可以像项目经理那样检查页面。 它的 /browser 指令启动一个沙盒浏览器子代理,点击每个下载按钮并截取屏幕截图。 IronPPT从文本、形状和图像在服务器上构建文档,这些元素在IronPPT的幻灯片元素教程中覆盖。 本指南使用这两个工具构建页面,并检查六个已知文档的项目。

本指南适用于开发人员使用AI代理编写在网络服务器上生成PowerPoint文件的.NET代码。 它不涉及幻灯片设计或企业模板。

快速入门
NuGet使用NuGet安装

PM > Install-Package IronPPT

通过在 NuGet 包管理器控制台中运行上述命令安装 IronPPT,或在 NuGet 包管理器中搜索该包。

在Antigravity中打开StatusDesk项目,描述状态页面。

/plan Give StatusDesk, the PMO's .NET 9 MVC site, a /Status page.
Each project row gets a Download status deck button.
The nav bar gets a Status link.
Install IronPPT 2026.10.1. Its namespace is IronPPT.
App_Data/projects.json holds the projects and the report week.

Each deck has these slides, in order:

1. Title: project name, "Status report, week of" plus the week, owner.
2. Status: status word, status-colored rectangle, summary, logo.
3. Milestones: name, due date and state, at most five per slide.
4. Risks: every risk, only if there are any.

Follow these rules too:

- Status colors: Green 00B050, Amber FFC000, Red C00000.
- Logo: App_Data/logos/<Id>.png, skipped if missing or unreadable.
- Text boxes don't overlap, and nothing runs off the slide IronPPT creates.
- Download name: status-<Id>.pptx, with the PowerPoint content type.
- If a deck fails, the page shows one plain sentence, never exception text.

Startup code reads IRONPPT_LICENSE_KEY itself and sets IronPPT.License.LicenseKey once.
Never print, log or store the key, or list environment variables.

Answer these in the Implementation Plan:

- What does a new PresentationDocument hold, and how big is its slide?
- Where does AddText put a text box, and what unit do Position, Width and Height use?
- How do the deck's bytes get into the HTTP response?

Show me the plan, then build until dotnet build shows zero errors.
Text

一个通过构建的结果无法证明三种答案中的任何一种,所以在批准前请在计划中阅读它们。

IronPPT本身不读取IRONPPT_LICENSE_KEY。 在我们的探测中,当单独设置该变量时,License.IsLicensed保持为false,而名为IronPPT.LicenseKey的环境变量在没有任何代码的情况下就授权了该过程。 在启动时分配License.LicenseKey可以使变量名保持在应用程序的控制之下。 许可证密钥指南描述了应用密钥的其他方法。



什么是Google Antigravity,它与聊天助手有何不同?

根据谷歌的概述,Antigravity应用程序是一个用于启动、编排和检查AI代理团队的独立桌面应用程序。 它的代理返回工件,如实施计划、演练和屏幕截图,而聊天助手返回文本。

一个在没有检查的情况下选择包名的代理可能会安装恶意软件,因为攻击者会发布语言模型幻想的包名。 这种攻击被称为slopsquatting。 在每个添加包的任务中都要命名IronPPT包及其版本。 AI编码助手指南列出了IronPPT文档的文件,供代理使用,其接受测试适合在一个提示中。

您应该在计划、代码更改和演练中检查什么?

在计划中,将每个答案与下面测量的文档内容进行比较。 在代码更改中,找到每个文本框接收其位置的位置,并在API参考中确认每个IronPPT成员。

演练应该包含每次下载的截图。 在桌面应用程序中,Antigravity将每个截图存储为图像工件,允许评论,因此错误的评论标识项目不需要新的提示。

您如何在真实浏览器中测试下载按钮?

为 /browser 提供一个表格,它只能通过下载每个文档并打开文件来完成。

/browser Launch StatusDesk with dotnet run as a background process.
Then open http://localhost:5326/Status.

Do this for every project, top to bottom:

1. Click Download status deck.
2. Save the file as artifacts/decks/status-<Id>.pptx.
3. Take a screenshot of the page.

Next, write a console tool in tools/DeckCheck that opens a deck with IronPPT.
It prints the slide count and each slide's text, shape count and image count.
Leave tools/DeckCheck out of the web project's compile items.

Run DeckCheck on each deck in artifacts/decks and compare it with TestData/expected-decks.csv.
Put the results in a Walkthrough table and in artifacts/deckcheck.md.
The table has these columns:

- project
- slides expected and slides found
- first text on slide 1
- images found
- pass or fail

If a row fails, trace the cause in the deck code before you edit.
Then fix it, restart the site and download every deck again.
At the end, kill the dotnet process by its PID and show me the table.
Text

这六个项目涵盖了状态文档需要处理的案例。 Atlas和Borealis有徽标和未解决的风险,Cobalt没有徽标文件,Delta没有风险,所以其文档在里程碑之后结束。 Ember的徽标包含一个来自失败导出的HTML错误页面而不是图像,Fjord有七个里程碑,需第二个里程碑幻灯片。

StatusDesk /状态页列出六个项目,每个项目都有一个下载状态牌按钮

P-102下载后的 /Status 页面,最终浏览器记录显示的样子,没有其样式表。

输出

下面的Borealis文档是最终浏览器下载的文件,没有改变。

下载状态-P-102.pptx

Borealis移动应用状态文档,四张幻灯片,第二张有徽标。

新的IronPPT文档在您添加任何内容之前包含什么?

每个新的PresentationDocument从一个幻灯片开始。该幻灯片使用标题幻灯片布局,并保留两个空的占位符,Title 1和Subtitle 2,AddSlide在其后面附加。 添加幻灯片指南中记录了现有的幻灯片。

幻灯片为4:3,720乘540点。 Position、Width和Height以点为单位取值,因此宽度为100时,写入1,270,000 EMU。 幻灯片元素教程中关于单位像素的评论对于IronPPT 2026.10.1是错误的。

Slide.AddText创建了一个没有位置的文本框,正如IronPPT中心文章所测量。 在Slide.TextBoxes的最后一个项上设置Position、Width和Height会放置该调用添加的盒子。 Font.FontFamily不在文件中写入字体,而Font.LatinFont会。

一个调用AddSlide并在缺乏位置的情况下使用AddText的校准构建在所有六个文档中打开空白幻灯片,每个文档中的6到15个文本框共享一个位置。 第二个构建复用了现有的幻灯片,并定位了每个文本框,通过了所有六个项目。

您如何设置Antigravity可以工作的项目?

在一个编译并服务页面的仓库上启动代理。 此指南项目是使用dotnet new mvc -f net9.0创建的,在第一次提示之前已构建一次。 在Properties/launchSettings.json中的http配置服务端口5326。

Which IronPPT version is in StatusDesk.csproj? Quote that PackageReference line.
Next, find and quote the code that sets the key.
Answer from the code without running the app.

Check the key handling against these rules:

- The key comes in through IRONPPT_LICENSE_KEY at startup and nowhere else.
- No appsettings file has an IronPPT.LicenseKey entry.
- The key isn't set in Properties/launchSettings.json either.
- If the variable is missing, startup logs a single warning with its name and no value.
- IronPPT licensing errors get logged by type name only, because their message can contain the key.

If that warning is missing, add it to Program.cs and change nothing else.
For each other rule that fails, give me the file and line.
Text

没有许可证密钥,IronPPT 2026.10.1在内存中构建了一个文档,并打开了一个现有的PPTX文件。Save引发了一个主题为“需要生产许可证”的LicensingException,且没有出现输出文件。 在校准页面上,第一个未授权的下载在871毫秒后失败,后续则在33到48毫秒之间失败。 一个处理程序必须通过类型名称匹配LicensingException,因为该类型不是公共的。

使用无效密钥时,LicensingException消息重复它所获得的密钥文本。 一个显示异常消息的校准下载在响应中返回该密钥文本。 记录消息的日志条目承载相同文本,因此上述规则仅记录类型名称。

如何将文档规则应用于后续任务?

每行通过时,即将会话决策记录为规则。 根据Antigravity的规则文档,CLI从存储库的根目录和子目录中读取AGENTS.md、GEMINI.md和.agents/rules。 /learn指令将会话中的更正汇总为持久性规则。

/learn Save what this session decided in a new AGENTS.md at the repo root.
Put it under the heading "Status decks" and cover these points:

- what a new PresentationDocument holds before any slide is added
- the unit of Position, Width and Height, and the slide size
- how each text box gets a position of its own
- how the deck's bytes reach the HTTP response
- that the key comes only from IRONPPT_LICENSE_KEY and is never printed, logged or stored
- that no command lists the environment variables
- that a change is done once every row of TestData/expected-decks.csv passes in /browser

Show me the file when you're done.
Text

如果多个人同时下载会发生什么?

IronPPT在同时处理两个请求时并不安全,即使每个请求都构建自己的PresentationDocument并保存到自己的文件。使用16个线程在内存中构建文档没有错误。 在平行线程上保存或加载失败,出现如InvalidOperationException和IOException的错误,以及未出现异常而保存的文件包含另一个文档的幻灯片。 在Save周围加锁并在加载和构建时保持未锁定,结果32个文档仍有1到10个失败。

在校准应用中,12个并行下载,每个项目两个,进行了三次运行。 没有锁的情况下,36个响应中30个返回HTTP 500,6个文档交付错误。 每个IronPPT调用周围都有一个锁,36个响应中都有正确的文档,最慢耗时1,066毫秒。

/plan On Monday mornings a dozen project managers download their decks within seconds of each other.
Write an Implementation Plan Artifact first, and wait for my approval before any edit.

Once I approve, measure the effect on the site before you touch the code:

1. Run the site in a separate process.
2. Send 12 download requests at once, two per project.
3. Save each response and check its slide count and title against TestData/expected-decks.csv.
4. Search each file for text from another project.
5. Count the failed responses and the files that don't match.

Then fix the root cause. Every download has to stay under two seconds.
After the fix, send the 12-request burst three more times.

Give me these results:

- the counts before the fix and for each later burst
- the first error from the log

End by stopping the site's dotnet process through its PID.
Text

预期服务类似于此示例,其使用IronPPT 2026.10.1进行编译。从其生成的文档在第一张幻灯片上保留空的Title 1和Subtitle 2占位符。若要删除它们,请在每个title.TextBoxes.ToList()项上调用Remove,然后进行第一次AddText调用。

using IronPPT;
using IronPPT.Enums;
using IronPPT.Models;

namespace StatusDesk.Services;

public sealed class DeckBuilder(IWebHostEnvironment env)
{
    // IronPPT is not safe to run on two requests at once, so every IronPPT call goes through this lock.
    private static readonly object IronPptLock = new();

    private static readonly Dictionary<string, string> StatusColors = new()
    {
        ["Green"] = "#00B050",
        ["Amber"] = "#FFC000",
        ["Red"] = "#C00000",
    };

    public byte[] Build(Project project, string reportWeek)
    {
        lock (IronPptLock)
        {
            var deck = new PresentationDocument();

            Slide title = deck.Slides[0];
            AddText(title, project.Name, x: 40, y: 180, width: 640, height: 70, points: 40, bold: true);
            AddText(title, $"Status report, week of {reportWeek}", x: 40, y: 260, width: 640, height: 40, points: 24);
            AddText(title, $"Owner: {project.Owner}", x: 40, y: 310, width: 640, height: 40, points: 20);

            Slide status = deck.AddSlide(new Slide());
            AddText(status, "Status", x: 40, y: 30, width: 500, height: 60, points: 32, bold: true);
            status.AddShape(new Shape
            {
                Type = ShapeType.Rectangle,
                FillColor = new Color(StatusColors[project.Status]),
                Position = (40, 110),
                Width = 160,
                Height = 60,
            });
            AddText(status, project.Status, x: 220, y: 120, width: 300, height: 40, points: 28, bold: true);
            AddText(status, project.Summary, x: 40, y: 200, width: 640, height: 120, points: 20);

            string logo = Path.Combine(env.ContentRootPath, "App_Data", "logos", project.Id + ".png");
            if (File.Exists(logo))
            {
                try
                {
                    var image = status.AddImage(logo);
                    image.Position = (560, 30);
                    image.Width = 120;
                    image.Height = 60;
                }
                catch (IronPPT.Models.Exceptions.ImageLoadException)
                {
                }
            }

            // Milestone and risk slides follow the same AddText pattern.

            string path = Path.Combine(Path.GetTempPath(), $"status-{Guid.NewGuid():N}.pptx");
            try
            {
                deck.Save(path);
                return File.ReadAllBytes(path);
            }
            finally
            {
                File.Delete(path);
            }
        }
    }

    private static void AddText(Slide slide, string text, double x, double y, int width, int height, double points, bool bold = false)
    {
        slide.AddText(new Text(text)
        {
            TextStyle = new TextStyle { IsBold = bold, TextFont = new Font { LatinFont = "Calibri", FontSize = points } },
        });
        var box = (TextBox)slide.TextBoxes[^1];
        box.Position = (x, y);
        box.Width = width;
        box.Height = height;
    }
}
C#

Save仅接受文件路径,因此示例写入一个临时文件并返回其字节。

何时应指派多个代理?

当部分检查不需要浏览器时,派遣第二个代理。

Split this work between two agents.

Agent A writes an xUnit project, StatusDesk.Tests, with these tests:

- For each row of TestData/expected-decks.csv, check the slide count and title text.
- Check the status rectangle's fill color in the saved file's slide XML.
- Build and save all six decks on parallel threads, then check each file holds only its project.

The tests follow AGENTS.md and these rules:

- They copy IRONPPT_LICENSE_KEY into IronPPT.License.LicenseKey before any save.
- They build decks through the site's own deck code and never start the site.
- The web project is the repo root, so its compile items skip StatusDesk.Tests.

Agent A runs them with dotnet test StatusDesk.Tests.

Agent B starts once that suite passes:

1. Use /browser to download every deck.
2. Send the 12-request burst again.
3. Put a screenshot of each download in the Walkthrough, and note there that the tests passed first.

Tell me what each agent found.
Text

使用IronPPT读取保存的文档测试能完整接收文本。 位置和大小返回的值比设置的值大12,700倍,填充和文字颜色返回为#00000000,所以颜色检查需要读取幻灯片的XML。

请注意: 在测试运行中,Agent B写了一份讲解而Agent A没有,所以在合并之前请阅读每个代理的最终回复。

在实际运行中这些提示生成了什么?

所有六个提示在一个Antigravity CLI对话中无人值守地运行,跳过了权限提示。 应用程序仅通过IRONPPT_LICENSE_KEY接收许可证密钥。 每个文档也独立下载并检查过,一次在第一个提示之后,一次在最终应用程序中。

  • 在任何编辑之前,计划发现新文档的首张幻灯片上有两个空占位符,构建删去了它们。
  • 第一个提示后,所有六个文档具有预期的幻灯片数量和标题。
  • 没有文本框重叠或超出幻灯片边缘,无论是在哪个检查中。
  • 在第一次构建中,三个12个并行下载的爆发返回3个、1个和3个正确的文档。
  • 在这些爆发中,36个请求中的27个接收到HTTP 200的错误页,而不是文档。
  • 杜交付的文档错误,一个Borealis移动应用文档含有Delta办公室搬迁项目名称。
  • 代理的修复方案是在构建和保存每个文档时添加一个锁。
  • 修复还在首次请求状态页时构建所有六个文档,并在项目数据或徽标更改之前将其字节保存在内存中。
  • 修复后,三个独立的爆发返回36个正确文档中的36个,最慢下载耗时14毫秒。 所有响应均来自保存在内存中的文档,因此这些爆发没有使用到锁。 并发部分的校准测试是显示锁定工作的测量。
  • 400乘200像素的徽标以152乘110点绘制,因此它们失真。
  • 没有密钥,页面显示“不能为该项目生成状态文档。”
  • 无效密钥既不出现在响应中,也不在日志中。
  • /learn在存储库根目录下写入了AGENTS.md,含有所有七个点。
  • 所有13个xUnit测试在有密钥时通过而无密钥时失败。
  • 两代理提示在各自的子对话中运行,每次测试通过,Agent B开始。
  • 有些步骤与页面中的运行不一样。 /browser子代理最初无法达到Chrome,所以代理自行开始带有远程调试的Chrome。 那一步还重写了用户的Chrome配置文件中的DevToolsActivePort文件。浏览器屏幕截图显示页面没有其样式表,但在独立检查中正常加载。 两个计划优先提示在计划后停下,直到运行发出批准。 设置检查报告了一个捕获块未记录任何内容,并发提示稍后替换了它。

ChatGPT Codex将任务的命名部分分配给探索者和工作者代理,GitHub Copilot将其固定规则保存在提交的指令文件中,本指南也将AGENTS.md这样做。 共享的运行记录在中心页上列出Antigravity的版本、模型、运行时长及测试机器。


故障排除


有问题吗?

如果您有任何问题,请联系support@ironsoftware.com

Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。

阅读更多

准备开始了吗?

NuGet 下载量 7,110版本:2026.11刚刚发布