| name | syncfusion-dotnet-word |
| description | Create, edit, format, and convert Word (.docx) documents using Syncfusion DocIO for .NET. Use this skill for Word processing and DOCX automation when the user asks to generate Word files, modify document content, insert tables or images, apply formatting, automate document workflows, or convert Word to PDF using C# code or CSX execution. |
| metadata | {"author":"Syncfusion Inc","version":"34.1.29"} |
Word (DOCX) Document Processing
Overview
Create, edit, and convert Word (.docx, .doc) files using the Syncfusion Word Library.
This skill supports two operational modes — generating C# code for the user's project or executing tasks directly through a CSX script.
Key Capabilities
- Create & Edit: Documents (.docx, .doc, .rtf, .txt, .xml), paragraphs, headings, styles, lists, tables, charts, shapes, images, hyperlinks, bookmarks, watermarks, headers/footers, form fields, content controls, SmartArt, OLE objects
- Advanced Features: Mail merge (DataTable, JSON, XML, custom objects), track changes, comments, mathematical equations (LaTeX), compare/split/merge documents, table of contents
- Conversion: Word to PDF (font embedding, PDF/A, accessibility), Word to Image (PNG, JPEG, BMP, TIFF), HTML ↔ DOCX, RTF ↔ DOCX, Text ↔ DOCX, XML ↔ DOCX
- Security: Password encryption/decryption, document protection with editable ranges, macro management
Prerequisites
Quick Start Examples
Example 1: Generate Code (Mode 1)
User: "Show me how to create a Word document with a table"
Result: C# code snippet displayed (no files created)
Example 2: Execute Task (Mode 2)
User: "Create a Word document with a table at output/report.docx"
Result: Physical file created at specified path
Two Modes — Choose Based on User Intent
Before choosing a mode, infer what the user wants to accomplish:
Mode 1: Generate C# Code for the User's Project (default)
Use this mode when the user wants to view, write, review, refactor, or modify C# code related to Word 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:
Step 1 — Detect the Application Type and Suggest the Correct NuGet Package(s)
- Inspect the workspace project files (
.csproj, web.config, App.config, Startup.cs, Program.cs, etc.) and use the detection signals table in references/nuget-packages.md to identify the application type.
- Look up the correct package(s) from
references/nuget-packages.md based on the detected app type and tell the user to install them before generating any code.
Step 2 — Generate Code from Reference Files Only
Do NOT invent, guess, or suggest any API, method, property, class, or namespace not explicitly present in the reference files.
- Read the relevant
references/*.md file(s) for the requested feature
- 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 MVC5) → use Windows-specific snippets
- Cross-platform apps (ASP.NET Core, .NET Core/.NET 5+ Console, Blazor, MAUI) → use cross-platform /
.Net.Core snippets
- Do not create or run any
.csx script
Mode 2: Execute via CSX Script (does not touch project files)
Use this mode only when the user explicitly requests execution, file generation, or a fully produced output (such as a completed Docx file).
Trigger keywords: "create a word document", "make a document", "generate a document", "open", "edit", "modify", "change" a .docx file, "without modifying my project", "run a csx script", or when the user provides a file path (e.g., output/report.docx).
Workflow:
Step 1 — Create Temp CSX Script
- Start with
references/template.csx as the base
- Create at:
{skill-root}/syncfusion-dotnet-word/scripts/temp-{uniqueId}.csx (e.g., skill-root = .codestudio/skills)
- Use random GUID for unique filename (e.g.,
temp-a3f7b2c1.csx); never create in workspace root
Step 2 — Build Script from Reference Files
- Do NOT invent APIs/methods not in reference files
- Read relevant
references/*.md file(s) and extract code snippets
- Replace all placeholders: file paths, document properties, data values, field names, etc.
Step 3 — Execute Script
- Run:
dotnet script {skill-root}/syncfusion-dotnet-word/scripts/temp-{uniqueId}.csx
- Verify successful execution and capture any errors
Step 4 — Clean Up and Report
- Delete the temp
.csx file after execution
- Report SUCCESS/ERROR with output file path(s) and any error messages with fixes
Code References
All templates and snippets are in the references/ folder:
| File | Contents |
|---|
| template.csx | Base CSX script structure (Mode 2 only) |
| document-structure.md | Create/load document, add sections, page setup, save to file or stream, supported formats |
| styles-and-formats.md | Paragraphs, headings, bullet & numbered lists |
| paragraph-and-styles.md | Add paragraphs, paragraph formatting, styles (built-in/custom), text formatting, tab stops, breaks, symbols, text boxes |
| tables.md | Create tables, cell formatting, merge cells |
| bookmarks.md | Create bookmarks, navigate, retrieve, insert, replace, delete content |
| charts.md | Create charts from scratch/Excel, modify data, refresh, customize elements, 3D formatting, convert to image |
| shapes.md | Add shapes, format, rotate, group, ungroup shapes |
| mail-merge.md | Simple field merge, merge with regions (groups), nested merge, DataTable, dynamic objects, business objects, DataView, XML, JSON, image merge fields, merge events (MergeField, MergeImageField, BeforeClearField, BeforeClearGroupField), field mapping, retrieve merge field names, remove empty paragraphs, clear fields option |
| form-fields.md | Add checkboxes, dropdowns, text input fields, modify properties |
| macros.md | Load/save macro-enabled documents (DOTM, DOCM), check for macros, remove macros, preserve macros through conversion |
| mathematical-equation.md | Create equations (fraction, radical, matrix, N-array, etc.), modify existing equations, LaTeX support, equation formatting |
| split-word-documents.md | Split documents by sections, headings, bookmarks, placeholder text |
| merge-word-documents.md | Merge documents in new page, same page, maintain imported list styles |
| table-of-contents.md | Add TOC, update, apply switches, custom styles, table of figures, remove TOC |
| compare-word-documents.md | Compare two Word documents, set author and date, comparison options, ignore format changes |
Rules
- Output files go in
./output/ directory
- Temp
.csx scripts must be created inside {skill-root}/syncfusion-dotnet-word/scripts/ — never in the workspace root or customer scripts/ folder
- Never use Python libraries (e.g., python-docx)
- Never leave temp
.csx files after execution