如何使用IronPPT和Google Antigravity

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

專案管理辦公室每週一為每個專案發佈狀態簡報。 在StatusDesk中,辦公室的Web應用程式中,專案經理點選專案行上的「下載狀態簡報」並接收伺服器剛剛生成的PowerPoint檔案。 簡報可以下載而無錯誤,卻可能打開後只有一個空白的首張幻燈片、文字框重疊或包含另一個專案的幻燈片。 這些錯誤都不會出現在建置日誌中。

Google Antigravity可以檢查頁面如同專案經理使用它的方式。 它的/browser指令啟動一個受沙盒保護的瀏覽器子代理,點擊每個下載按鈕並捕捉螢幕截圖。 IronPPT從文字、圖形和圖片這些IronPPT 的 幻燈片元素教程中涵蓋的元素在伺服器上生成簡報。 本指南使用這兩種工具搭建頁面,並根據已知的六個專案檢查其簡報。

本指南適用於使用AI代碼編寫.NET代碼,從而生成Web伺服器上的PowerPoint檔案的開發人員。 它並不涉及幻燈片設計或企業模板。

快速開始
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仍然為假,而由環境變數命名的IronPPT.LicenseKey在不需要任何代碼的情況下授權了該過程。 在啟動時指派License.LicenseKey可以確保變數名稱由應用程式控制。 授權金鑰指南描述了應用金鑰的其他方法。



Google Antigravity是什麼,它與聊天助手有何不同?

根據Google的概覽,Antigravity App是用於啟動、協作與檢查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後的/狀態頁面,作為最終瀏覽器通過截取時未帶樣式表的頁面。

輸出

下面的Borealis簡報是最終瀏覽器通過下載的檔案,未更改。

下載狀態-P-102.pptx

Borealis行動應用狀態簡報,第二頁有徽標,共四張幻燈片。

在添加任何內容之前新IronPPT簡報包含哪些內容?

每個新的PresentationDocument以一個幻燈片開始。該幻燈片使用標題幻燈片佈局,保留兩個空置的佔位符,標題 1 和副標題 2,並在其後附加AddSlide。 添加幻燈片指南記錄了現有的幻燈片。

該幻燈片為4:3比例,720 x 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創建的,並在第一次提示前建置了一次。 其 http 設定檔在 Properties/launchSettings.json中服務於埠 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份送達的簡報中有4份有誤。 為每個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編譯。從中構建的幻燈片在首張幻燈片上保留空置的標題1和副標題2佔位符。要刪除它們,請在首次 AddText 呼叫前針對 title.TextBoxes.ToList() 的每個項目調用 Remove。

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。

請注意: 在測試運行中,代理B 編寫了一個流程演示,而代理A則未編寫,因此在合併之前閱讀每個代理的最終回覆。

在實際運行中,這些提示產生了什麼結果?

所有六個提示都在一個Antigravity CLI對話中無監管運行,並跳過了許可提示。 應用程式只通過IRONPPT_LICENSE_KEY接收授權金鑰。 每個簡報也獨立下載和檢查一次,在首次提示之後和最終應用程式中。

  • 在任何編輯之前,計劃在一份新的文件的首張幻燈片上找到了兩個空佔位符,並將其刪除。
  • 在第一個提示後,所有六個簡報都有預期的幻燈片數和標題。
  • 在兩次檢查中,沒有文本框重疊或超出幻燈片邊緣。
  • 在第一次建置中,三批12次並行下載返回了3、1和3個正確簡報。
  • 在這些陣列中,36次請求中有27次接收到錯誤頁面,帶有HTTP 200,而非簡報。
  • 兩份送達的簡報有誤,其中一份Borealis Mobile App簡報包含了Delta Office Move項目的名字。
  • 代理的修補為每次簡報的構建和保存使用了一個鎖。
  • 修補還在對狀態頁的第一次請求時構建了所有六份簡報,並在專案資料或徽標改變時將其位元組保存在內存中。
  • 修補後,三個獨立的爆發返回36個正確簡報中的36個,最慢的下載花了14毫秒。 每個響應都來自保存在內存中的簡報,因此這些爆發並沒有使用到鎖。 並發部份的校驗測試是顯示鎖成功工作的測量。
  • 400 x 200像素的徽標以152 x 110點繪製,這使它們變形。
  • 沒有金鑰的情況下,頁面顯示“無法生成該專案的狀態簡報。”
  • 回應中和日誌中均未出現無效的金鑰。
  • /learn在倉庫根目錄寫入AGENTS.md,其中包含所有七個要點。
  • 所有13個xUnit測試都在有鑰時通過,沒有鑰時失敗。
  • 雙代理提示在每個代理的子對話中運行,每個代理在測試通過後開始,代理B
  • 一些步驟與頁面上運行的不同。 在首次,/browser子代理無法訪問Chrome,因此代理自己以遠端調試啟動了Chrome。 那個步驟還重寫了用戶Chrome配置文件中的DevToolsActivePort文件。瀏覽器螢幕截圖顯示是沒有樣式表的頁面,而在獨立檢查中正常載入。 兩個計劃第一次提示在計劃後停止,直到運行發送批准。 施工檢查報告一個捕獲塊不再記錄任何內容,並發生在後來受限提示中。

ChatGPT Codex將任務的命名部分分配給explorer和worker代理,GitHub Copilot在提交的指令文件中保留其固定規則,就像本指南在AGENTS.md中一樣。 共享運行記錄在樞軸頁上列出Antigravity的版本、模型、運行的持續時間和測試機器。


疑難排解


問題?

如果您有任何疑問,請聯繫support@ironsoftware.com

Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。

閱讀更多

準備好開始了嗎?

NuGet 下載次數 7,110版本:2026.11剛剛發布