syncfusion-dotnet-powerpoint
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePowerPoint (PPTX) Presentation Processing
PowerPoint(PPTX)演示文稿处理
Overview
概述
Create, edit and convert PowerPoint (.pptx) files using the Syncfusion Presentation Library.
This skill supports two operational modes — generating C# code for the user’s project or executing tasks directly through a CSX script.
使用Syncfusion Presentation Library创建、编辑和转换PowerPoint(.pptx)文件。
此技能支持两种操作模式——为用户项目生成C#代码,或通过CSX脚本直接执行任务。
Key Capabilities
核心功能
- Create & Edit: Presentations (.pptx), slides (clone and merge), paragraphs, text boxes, tables, shapes, images, lists, connectors, hyperlinks, headers/footers, comments, document properties, sections
- Advanced Features: Custom animations and slide transitions, master slide layouts, speaker notes, SmartArt, OLE objects, find and replace, macros, chart creation and editing, chart-to-image conversion
- Conversion: PowerPoint to PDF; PowerPoint to images (PNG, JPEG)
- Security: Encrypt and decrypt presentations; set and remove write protection
- 创建与编辑: 演示文稿(.pptx)、幻灯片(克隆与合并)、段落、文本框、表格、形状、图片、列表、连接线、超链接、页眉/页脚、批注、文档属性、节
- 高级功能: 自定义动画和幻灯片切换效果、母版幻灯片版式、演讲者备注、SmartArt、OLE对象、查找和替换、宏、图表创建与编辑、图表转图片
- 转换: PowerPoint转PDF;PowerPoint转图片(PNG、JPEG)
- 安全: 加密和解密演示文稿;设置和移除写保护
Prerequisites
前提条件
- .NET SDK 8+ and :
dotnet-scriptdotnet tool install -g dotnet-script - Syncfusion License: or env var
SyncfusionLicense.txtSYNCFUSION_LICENSE_KEY - Free license: https://www.syncfusion.com/products/communitylicense
- .NET SDK 8+ 和 :
dotnet-scriptdotnet tool install -g dotnet-script - Syncfusion许可证:或环境变量
SyncfusionLicense.txtSYNCFUSION_LICENSE_KEY - 免费许可证:https://www.syncfusion.com/products/communitylicense
Quick Start Examples
快速入门示例
Example 1: Generate Code (Mode 1)
示例1:生成代码(模式1)
User: "Show me how to create a PowerPoint presentation with a simple bar chart"
Result: C# code snippet displayed (no files created)
用户: "展示如何创建包含简单条形图的PowerPoint演示文稿"
结果: 显示C#代码片段(不创建文件)
Example 2: Execute Task (Mode 2)
示例2:执行任务(模式2)
User: "Create a PowerPoint presentation with a simple bar chart at output/SalesChart.pptx"
Result: Physical file created at with the chart embedded
output/SalesChart.pptx用户: "在output/SalesChart.pptx路径下创建包含简单条形图的PowerPoint演示文稿"
结果: 在路径下创建包含嵌入图表的实体文件
output/SalesChart.pptxTwo Modes — Select Based on User Intent
两种模式——根据用户意图选择
Mode 1: Generate C# Code for the User's Project (default)
模式1:为用户项目生成C#代码(默认)
Use this mode when the user wants to view, write, review, refactor, or modify C# code related to PowerPoint processing.
Trigger keywords: "show me how", "how to", "how can I", "how do I", "provide code", "provide an example", "give an example", "demonstrate", "code snippet", "sample code", "example", "sample", "give me", "show me", "Program.cs", "example code", "generate code for", "codesnippet" .
Workflow:
当用户想要查看、编写、审阅、重构或修改与PowerPoint处理相关的C#代码时,使用此模式。
触发关键词: "show me how"、"how to"、"how can I"、"how do I"、"provide code"、"provide an example"、"give an example"、"demonstrate"、"code snippet"、"sample code"、"example"、"sample"、"give me"、"show me"、"Program.cs"、"example code"、"generate code for"、"codesnippet"。
工作流程:
Step 1 — Detect Application Type and Suggest Required NuGet Packages
步骤1——检测应用类型并建议所需NuGet包
- Inspect the workspace project files (,
.csproj,web.config,App.config,Startup.cs, etc.) and use the detection signals table inProgram.csto determine the application type.references/nuget-packages.md - Based on the detected application type, identify the correct NuGet package(s) from references/nuget-packages.md and instruct the user to install them before generating any code.
- 检查工作区项目文件(、
.csproj、web.config、App.config、Startup.cs等),使用Program.cs中的检测信号表确定应用类型。references/nuget-packages.md - 根据检测到的应用类型,从references/nuget-packages.md中识别正确的NuGet包,并指导用户在生成任何代码之前安装它们。
Step 2 — Generate Code from Reference Files Only
步骤2——仅从参考文件生成代码
Do NOT invent, guess, or suggest any API, method, property, class, or namespace not explicitly present in the reference files.
- Read the relevant file(s) for the requested feature
references/*.md - Build C# code strictly from the APIs and snippets found in those files
- Select the correct snippet variant based on the app type detected in Step 1:
- Windows-specific apps (WinForms, WPF, .NET Framework Console, ASP.NET MVC4/5 ) → use Windows-specific snippets
- Cross-platform apps (ASP.NET Core, .NET Core/.NET 5+ Console, Blazor, MAUI) → use cross-platform / snippets
.Net.Core
- Do not create or run any script
.csx
请勿发明、猜测或建议任何未在参考文件中明确提及的API、方法、属性、类或命名空间。
- 读取与所需功能相关的文件
references/*.md - 严格从这些文件中的API和片段构建C#代码
- 根据步骤1中检测到的应用类型选择正确的片段变体:
- Windows专属应用(WinForms、WPF、.NET Framework控制台、ASP.NET MVC4/5)→ 使用Windows专属片段
- 跨平台应用(ASP.NET Core、.NET Core/.NET 5+控制台、Blazor、MAUI)→ 使用跨平台/片段
.Net.Core
- 请勿创建或运行任何脚本
.csx
Mode 2: Execute via CSX Script (does not touch project files)
模式2:通过CSX脚本执行(不修改项目文件)
Use this mode only when the user explicitly requests execution, file generation, or a fully produced output (such as a completed PPTX file).
Trigger keywords: "create a presentation", "make a presentation", "generate a presentation", "open", "edit", "modify", "change" a file, "without modifying my project", "run a csx script", or when the user provides a file path (e.g., ).
.pptxoutput/report.pptxWorkflow:
仅当用户明确要求执行、生成文件或完整输出(如已完成的PPTX文件)时,使用此模式。
触发关键词: "create a presentation"、"make a presentation"、"generate a presentation"、"open"、"edit"、"modify"、"change" a file、"without modifying my project"、"run a csx script",或当用户提供文件路径时(例如)。
.pptxoutput/report.pptx工作流程:
Step 1 — Create Temp CSX Script
步骤1——创建临时CSX脚本
- Start with as the base
references/template.csx - Create at: (e.g.,
{skill-root}/syncfusion-dotnet-powerpoint/scripts/temp-{uniqueId}.csx=skill-root).codestudio/skills - Use random GUID for unique filename (e.g., ); never create in workspace root
temp-a3f7b2c1.csx
- 以为基础
references/template.csx - 创建路径:(例如
{skill-root}/syncfusion-dotnet-powerpoint/scripts/temp-{uniqueId}.csx=skill-root).codestudio/skills - 使用随机GUID作为唯一文件名(例如);切勿在工作区根目录创建
temp-a3f7b2c1.csx
Step 2 — Build Script from Reference Files
步骤2——从参考文件构建脚本
- Do NOT invent APIs/methods not in reference files
- Read relevant file(s) and extract code snippets
references/*.md - Replace all placeholders: file paths, document properties, data values, field names, etc.
- 请勿发明参考文件中未包含的API/方法
- 读取相关的文件并提取代码片段
references/*.md - 替换所有占位符:文件路径、文档属性、数据值、字段名等
Step 3 — Execute Script
步骤3——执行脚本
- Run:
dotnet script {skill-root}/syncfusion-dotnet-powerpoint/scripts/temp-{uniqueId}.csx - Verify successful execution and capture any errors
- 运行:
dotnet script {skill-root}/syncfusion-dotnet-powerpoint/scripts/temp-{uniqueId}.csx - 验证执行是否成功并捕获任何错误
Step 4 — Clean Up and Report
步骤4——清理并报告
- Delete the temp file after execution
.csx - Report SUCCESS/ERROR with output file path(s) and any error messages with fixes
- 执行完成后删除临时文件
.csx - 报告成功/错误信息,包含输出文件路径及任何错误消息和修复方案
Code References
代码参考
All templates and snippets are in the folder:
references/| File | Contents |
|---|---|
| template.csx | Base CSX script structure (Mode 2 only) |
| presentation-structure.md | Create/save/close presentation, slide layout, page size, document properties |
| slides.md | Add, remove, resize, and customize PowerPoint slides, print slides |
| layout.md | Access, customize, and create master slides and layout slides |
| paragraph.md | Add, format, and manage paragraphs in textboxes and shapes |
| sections.md | Create and Modify Sections in presentation |
| tables.md | Create and modify tables in presentation |
| shapes.md | Add, iterate, format, and remove shapes (AutoShapes, pictures, text boxes, group shapes) in a presentation |
| connectors.md | Add, edit, update, and remove connectors between shapes |
| image.md | Add, replace, crop, and remove images including SVG support |
| list.md | Create numbered, bulleted, picture, and multi-level lists |
| chart.md | Create and edit chart in presentation |
| animation-transition.md | Add, modify slide transition and annimation effect in presentation |
| comments.md | Add, Reply, Modify, Delete commments in presentation |
| header-footer.md | Add, edit, and remove headers and footers including slide numbers and dates |
| notes.md | Add, edit, format, and remove speaker notes in presentations |
| ole-objects.md | Insert, extract, and manage OLE objects (Excel, Word, Visio) in slides |
| conversions.md | Convert Presentation to image and Pdf |
| encrypt-decrypt.md | Security: Protect, encrypt, and decrypt during read or write access in presentations |
| find-and-replace.md | Find and Replace, Find and highlight in specific slide or in presentation |
| smartart.md | Create a SmartArt, Add, Edit, Remove nodes in SmartArt in a PowerPoint Presentation |
| hyperlinks.md | Add or Modify Web, Email, Bookmark, File, Image hyperlinks |
| macros.md | Load, Save, Remove and manage macros in presentations |
所有模板和片段都位于文件夹中:
references/| 文件 | 内容 |
|---|---|
| template.csx | 基础CSX脚本结构(仅模式2可用) |
| presentation-structure.md | 创建/保存/关闭演示文稿、幻灯片版式、页面大小、文档属性 |
| slides.md | 添加、删除、调整大小和自定义PowerPoint幻灯片、打印幻灯片 |
| layout.md | 访问、自定义和创建母版幻灯片和版式幻灯片 |
| paragraph.md | 在文本框和形状中添加、格式化和管理段落 |
| sections.md | 在演示文稿中创建和修改节 |
| tables.md | 在演示文稿中创建和修改表格 |
| shapes.md | 在演示文稿中添加、遍历、格式化和删除形状(自选图形、图片、文本框、组合形状) |
| connectors.md | 在形状之间添加、编辑、更新和删除连接线 |
| image.md | 添加、替换、裁剪和删除图片,包括SVG支持 |
| list.md | 创建编号、项目符号、图片和多级列表 |
| chart.md | 在演示文稿中创建和编辑图表 |
| animation-transition.md | 在演示文稿中添加、修改幻灯片切换和动画效果 |
| comments.md | 在演示文稿中添加、回复、修改、删除批注 |
| header-footer.md | 添加、编辑和删除页眉和页脚,包括幻灯片编号和日期 |
| notes.md | 在演示文稿中添加、编辑、格式化和删除演讲者备注 |
| ole-objects.md | 在幻灯片中插入、提取和管理OLE对象(Excel、Word、Visio) |
| conversions.md | 将演示文稿转换为图片和Pdf |
| encrypt-decrypt.md | 安全:在演示文稿的读写过程中进行保护、加密和解密 |
| find-and-replace.md | 在特定幻灯片或整个演示文稿中查找和替换、查找并高亮显示 |
| smartart.md | 在PowerPoint演示文稿中创建SmartArt、添加、编辑、删除SmartArt节点 |
| hyperlinks.md | 添加或修改网页、邮件、书签、文件、图片超链接 |
| macros.md | 在演示文稿中加载、保存、删除和管理宏 |
Rules
规则
- Output files go in directory
./output/ - Temp scripts must be created inside
.csx— never in the workspace root or customer{skill-root}/syncfusion-dotnet-powerpoint/scripts/folderscripts/ - Use license key from at workspace root or env var
SyncfusionLicense.txtSYNCFUSION_LICENSE_KEY - Never use Python libraries (e.g., python-pptx)
- Never leave temp files after execution
.csx
- 输出文件保存至目录
./output/ - 临时脚本必须在
.csx目录下创建——切勿在工作区根目录或客户的{skill-root}/syncfusion-dotnet-powerpoint/scripts/文件夹中创建scripts/ - 使用工作区根目录下的或环境变量
SyncfusionLicense.txt中的许可证密钥SYNCFUSION_LICENSE_KEY - 切勿使用Python库(例如python-pptx)
- 执行完成后切勿保留临时文件
.csx