# Devexpress Office File Api Ai Powered Extensions

> Build .NET applications with the DevExpress AI-Powered Extensions for Office File API to add NLP-powered document processing capabilities — proofreading, translation, and text transformation for Word documents, PDF files, and PowerPoint presentations. Use when integrating AI language models (Azure OpenAI, OpenAI, Ollama, Google Gemini) with document processing workflows, translating documents pro…

- **Type:** Skill
- **Install:** `agentstack add skill-devexpress-agent-skills-devexpress-office-file-api-ai-powered-extensions`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [DevExpress](https://agentstack.voostack.com/s/devexpress)
- **Installs:** 0
- **Category:** [Cloud & Infrastructure](https://agentstack.voostack.com/c/cloud-infrastructure)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [DevExpress](https://github.com/DevExpress)
- **Source:** https://github.com/DevExpress/agent-skills/tree/main/plugins/dx-office-file-api/skills/devexpress-office-file-api-ai-powered-extensions
- **Website:** https://www.devexpress.com

## Install

```sh
agentstack add skill-devexpress-agent-skills-devexpress-office-file-api-ai-powered-extensions
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# DevExpress AI-Powered Extensions for Office File API

The DevExpress AI-Powered Extensions integrate language models into the Office File API through the `Microsoft.Extensions.AI` (`IChatClient`) abstraction. Extensions support proofreading, translation, summarization, and contextual Q&A (Ask AI) for Word Processing documents, PDF files, and PowerPoint presentations. Both cloud providers (Azure OpenAI, OpenAI, Google Gemini) and local models (Ollama, ONNX Runtime, AI Foundry Local) are supported. The API follows a BYOK ("bring your own key") model — no DevExpress-hosted LLM is included.

## When to Use This Skill

Use this skill when you need to:

- Proofread a Word document (.docx) or PowerPoint presentation with AI (grammar, spelling, style)
- Translate a Word document, PDF file, or PowerPoint presentation to another language
- Translate a specific paragraph, range, slide, or page region rather than the whole document
- Summarize the content of a Word document, PDF file, or presentation
- Ask contextual questions about document content using RAG (Retrieval-Augmented Generation)
- Register an AI provider (Azure OpenAI, OpenAI, Ollama, Gemini, ONNX, AI Foundry Local) with the DevExpress container
- Use the `AIDocProcessingService` or `IAIDocProcessingService` in a console app or ASP.NET Core / Blazor application
- Preserve formatting while performing AI-powered document transformations
- Process documents in a headless / server-side .NET environment without a UI control

## Prerequisites & Installation

### NuGet Packages

| Package | Purpose |
|---------|---------|
| `DevExpress.AIIntegration` | Core AI container and `IChatClient` wiring |
| `DevExpress.AIIntegration.Docs` | Office File API AI extensions (`AIDocProcessingService`) |
| `DevExpress.Document.Processor` | Word Processing and Spreadsheet document engines |
| `DevExpress.Docs.Presentation` | Presentation (PPTX) document engine |

Plus **one** AI provider package group (choose one):

| Provider | Required Packages |
|----------|------------------|
| Azure OpenAI | `Azure.AI.OpenAI` (2.2.0-beta.5), `Microsoft.Extensions.AI.OpenAI` (9.7.1-preview) |
| OpenAI | `OpenAI` (2.2.0), `Microsoft.Extensions.AI.OpenAI` (9.7.1-preview) |
| Ollama (self-hosted) | `OllamaSharp` |
| Google Gemini / Claude (Semantic Kernel) | `Microsoft.SemanticKernel`, `Microsoft.SemanticKernel.Connectors.*` |
| AI Foundry Local | `Microsoft.AI.Foundry.Local` (0.8.2.1+), `Microsoft.Extensions.AI.OpenAI` |
| ONNX Runtime | `Microsoft.ML.OnnxRuntimeGenAI` |

### .NET CLI (Azure OpenAI example)

```bash
dotnet add package DevExpress.AIIntegration
dotnet add package DevExpress.AIIntegration.Docs
dotnet add package DevExpress.Document.Processor
dotnet add package DevExpress.Docs.Presentation
dotnet add package Azure.AI.OpenAI --version 2.2.0-beta.5
dotnet add package Microsoft.Extensions.AI.OpenAI --version 9.7.1-preview.1.25365.4
```

**Important**: All DevExpress packages must share the same version. A valid DevExpress Universal or Office File API Subscription is required. Supported runtimes: .NET 8+ or .NET Framework 4.7.2.

## Before You Start — Ask the Developer

Before generating code, ask these questions to avoid rework:

### General Questions
1. **Target framework**: .NET 8+ or .NET Framework 4.7.2?
2. **New or existing project?**: Creating new or adding to an existing one?
3. **Hosting model**: Console app, ASP.NET Core, Blazor, or other?

### AI Extensions-Specific Questions
4. **AI provider**: Azure OpenAI / OpenAI / Google Gemini / Ollama / ONNX / AI Foundry Local / other `IChatClient`?
5. **Document type**: Word (.docx) / PDF / PowerPoint (.pptx)?
6. **Operation scope**: Entire document, or a specific section (paragraph, page range, slide range, coordinate region)?
7. **Operation**: Proofread / translate to target language / summarize / Ask AI — if translate or proofread, what target culture (e.g., `de-DE`, `es-ES`)?

> **Rule**: If any answer is ambiguous or missing, ask before generating code. Do not guess provider credentials or culture codes.

## Component Overview

The AI-Powered Extensions provide:

- **AI Container registration**: Creates the `AIExtensionsContainerDefault` that holds the registered `IChatClient` (`AIExtensionsContainerConsole.CreateDefaultAIExtensionContainer`)
- **Document processing service**: `AIDocProcessingService` (implements `IAIDocProcessingService`) — entry point for all AI operations
- **Proofread**: Reviews spelling, grammar, punctuation, and style; applies corrections in-place (`ProofreadAsync`)
- **Translate**: Translates document content or a range to a target culture; preserves formatting (`TranslateAsync`)
- **Summarize**: Returns abstractive or extractive text summary of document content (`SummarizeAsync`)
- **Ask AI (RAG)**: Answers natural language questions about document content using retrieval-augmented generation (`AskAIAsync`)

### Core Setup Pattern

```csharp
using DevExpress.AIIntegration;
using DevExpress.AIIntegration.Docs;
using Microsoft.Extensions.AI;

// 1. Build an IChatClient for your chosen provider (Azure OpenAI shown here)
IChatClient client = new Azure.AI.OpenAI.AzureOpenAIClient(
        new Uri("YOUR_AZURE_OPENAI_ENDPOINT"),
        new System.ClientModel.ApiKeyCredential("YOUR_AZURE_OPENAI_KEY"))
    .GetChatClient("gpt-4o-mini")
    .AsIChatClient();

// 2. Create the DevExpress AI extensions container
AIExtensionsContainerDefault container =
    AIExtensionsContainerConsole.CreateDefaultAIExtensionContainer(client);

// 3. Create the document processing service
IAIDocProcessingService docService = container.CreateAIDocProcessingService();
```

## Documentation & Navigation Guide

### Getting Started
Refer to [references/getting-started.md](references/getting-started.md)

When you need to:
- Install all required NuGet packages for a specific provider
- Register an AI provider and create the `AIExtensionsContainerDefault`
- Create the `IAIDocProcessingService` in a console or ASP.NET Core app
- Run your first proofread and translate operation end-to-end
- Understand async patterns and `CancellationToken` usage

### Word Processing Extensions
Refer to [references/word-processing-extensions.md](references/word-processing-extensions.md)

When you need to:
- Proofread an entire Word document or a specific paragraph range
- Translate a Word document or a specific `DocumentRange` to a target culture
- Summarize a Word document (abstractive or extractive)
- Ask contextual questions about a Word document's content (AskAI / RAG)
- Save the modified document after AI operations

### PDF Extensions
Refer to [references/pdf-extensions.md](references/pdf-extensions.md)

When you need to:
- Translate an entire PDF document (returns translated text string)
- Translate a specific page region using `PdfDocumentArea` coordinates
- Summarize a PDF document
- Ask contextual questions about a PDF document

### Presentation Extensions
Refer to [references/presentation-extensions.md](references/presentation-extensions.md)

When you need to:
- Proofread an entire PowerPoint presentation or a specific slide
- Translate an entire presentation or a single `Slide` to a target culture
- Summarize a presentation
- Save the modified presentation after AI operations

## Quick Start Example

Complete minimal example — proofread a Word document with Azure OpenAI:

```csharp
using DevExpress.AIIntegration;
using DevExpress.AIIntegration.Docs;
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
using Microsoft.Extensions.AI;
using System.Globalization;

// Configure credentials (use environment variables in production)
string endpoint = "YOUR_AZURE_OPENAI_ENDPOINT";
string apiKey   = "YOUR_AZURE_OPENAI_KEY";
string model    = "gpt-4o-mini";

// Build IChatClient
IChatClient client = new Azure.AI.OpenAI.AzureOpenAIClient(
        new Uri(endpoint),
        new System.ClientModel.ApiKeyCredential(apiKey))
    .GetChatClient(model)
    .AsIChatClient();

// Create AI extensions container and service
AIExtensionsContainerDefault container =
    AIExtensionsContainerConsole.CreateDefaultAIExtensionContainer(client);
IAIDocProcessingService docService = container.CreateAIDocProcessingService();

// Proofread a Word document
using (var wordProcessor = new RichEditDocumentServer())
{
    wordProcessor.LoadDocument("input.docx");
    await docService.ProofreadAsync(wordProcessor, new CultureInfo("en-US"));
    wordProcessor.SaveDocument("proofread_output.docx", DocumentFormat.OpenXml);
}
```

### What This Does
Loads `input.docx`, sends the text to the configured language model for grammar and spelling review, applies corrections in-place, and saves the result to `proofread_output.docx`. All operations are async — use `await` throughout.

## Key Properties & API Surface

### AIExtensionsContainerConsole

| Method | Return Type | Description |
|--------|-------------|-------------|
| `CreateDefaultAIExtensionContainer(IChatClient, ...)` | `AIExtensionsContainerDefault` | Creates an AI container pre-configured for console/server apps |

### AIDocProcessingExtensions (extension methods on `AIExtensionsContainer`)

| Method | Return Type | Description |
|--------|-------------|-------------|
| `CreateAIDocProcessingService()` | `IAIDocProcessingService` | Creates a document processing service from the container |
| `RegisterAIDocProcessingService()` | `AIExtensionsContainerSettings` | Registers services in a DI container (ASP.NET Core / Blazor) |

### IAIDocProcessingService — Key Overloads

| Method Signature | Description |
|-----------------|-------------|
| `ProofreadAsync(RichEditDocumentServer, CultureInfo, CancellationToken)` | Proofread entire Word document |
| `ProofreadAsync(DocumentRange, CultureInfo, CancellationToken)` | Proofread a specific range |
| `ProofreadAsync(Presentation, CultureInfo, CancellationToken)` | Proofread entire presentation |
| `ProofreadAsync(Slide, CultureInfo, CancellationToken)` | Proofread a specific slide |
| `TranslateAsync(DocumentRange, CultureInfo, CancellationToken)` | Translate a Word document range (in-place) |
| `TranslateAsync(Presentation, CultureInfo, CancellationToken)` | Translate entire presentation (in-place) |
| `TranslateAsync(Slide, CultureInfo, CancellationToken)` | Translate a single slide (in-place) |
| `TranslateAsync(PdfDocumentProcessor, CultureInfo, CancellationToken)` | Translate entire PDF (returns `Task`) |
| `TranslateAsync(PdfDocumentProcessor, PdfDocumentArea, CultureInfo, CancellationToken)` | Translate PDF region (returns `Task`) |
| `SummarizeAsync(RichEditDocumentServer, SummarizationMode, CancellationToken)` | Summarize Word document |
| `SummarizeAsync(PdfDocumentProcessor, SummarizationMode, CancellationToken)` | Summarize PDF document |
| `SummarizeAsync(Presentation, SummarizationMode, CancellationToken)` | Summarize presentation |
| `AskAIAsync(RichEditDocumentServer, string, RagOptions, CancellationToken)` | RAG Q&A on Word document |
| `AskAIAsync(PdfDocumentProcessor, string, RagOptions, CancellationToken)` | RAG Q&A on PDF document |
| `AskAIAsync(Presentation, string, RagOptions, CancellationToken)` | RAG Q&A on presentation |

## Common Patterns

### Translate a Specific Paragraph (Word)

```csharp
using (var wordProcessor = new RichEditDocumentServer())
{
    wordProcessor.LoadDocument("input.docx");
    Paragraph para = wordProcessor.Document.Paragraphs[1];
    await docService.TranslateAsync(para.Range, new CultureInfo("de-DE"));
    wordProcessor.SaveDocument("translated.docx", DocumentFormat.Docx);
}
```

### Translate a Specific Slide (PowerPoint)

```csharp
var presentation = new Presentation(File.ReadAllBytes("input.pptx"));
await docService.TranslateAsync(presentation.Slides[0], new CultureInfo("de-DE"));
using var outputStream = File.OpenWrite("translated.pptx");
presentation.SaveDocument(outputStream, DocumentFormat.Pptx);
outputStream.Close();
```

### Translate a PDF Area and Append as New Page

```csharp
using var pdf = new PdfDocumentProcessor();
pdf.LoadDocument("input.pdf");
var box = pdf.Document.Pages[0].CropBox;
var area = PdfDocumentArea.Create(
    new PdfDocumentPosition(1, box.TopLeft),
    new PdfDocumentPosition(1, box.BottomRight));
string translatedText = await docService.TranslateAsync(pdf, area, new CultureInfo("es-ES"));
// Render translatedText onto a new page, then save
pdf.SaveDocument("output.pdf");
```

### Register in ASP.NET Core / Blazor

```csharp
// Program.cs
IChatClient chatClient = azureOpenAIClient.GetChatClient(modelName).AsIChatClient();
builder.Services.AddSingleton(chatClient);
builder.Services.AddDevExpressAIConsole((config) => {
    config.RegisterAIDocProcessingService();
});
```

## Troubleshooting

| Symptom | Cause | Solution |
|---------|-------|----------|
| `Could not load file or assembly 'DevExpress.AIIntegration'` | Package not installed | Add `DevExpress.AIIntegration` and `DevExpress.AIIntegration.Docs` NuGet packages |
| `InvalidOperationException` on `CreateAIDocProcessingService` | Container was not initialized with a valid client | Ensure `AIExtensionsContainerConsole.CreateDefaultAIExtensionContainer(client)` is called before creating the service |
| Translation/proofread returns unchanged text | Model name is wrong or endpoint is unreachable | Verify `endpoint`, `apiKey`, and `modelName` values; test connectivity to the AI provider |
| `NullReferenceException` on `Paragraphs[n]` | Paragraph index out of range | Check `wordProcessor.Document.Paragraphs.Count` before indexing |
| PDF translate returns empty string | PDF contains only images or non-text content | AI extensions work only with text content in PDFs — annotations, images, and field values are not processed |
| Version mismatch build error | Mixed DevExpress package versions | Ensure all `DevExpress.*` packages use the exact same version (e.g., all 25.2.x) |
| License error at runtime | Missing DevExpress license | Register your license per the DevExpress installation guide; ensure the license file is deployed |
| `AskAIAsync` gives inaccurate counts | RAG limitation | The Ask AI extension may be inaccurate for questions requiring exact counts of elements |

## Constraints & Rules

## Security — Prompt Injection Protection

DevExpress AI-powered extensions include **automatic prompt-injection protection** (enabled by default). When extensions process user-provided content (documents, messages, clipboard data), malicious instructions embedded in that content could attempt to override system behavior, extract sensitive information, or manipulate model output — this is an indirect prompt injection attack.

The protection adds system-level instructions to every AI request so the LLM can identify and disregard injected instructions. This is transparent to the calling code — no configuration is required. See also: `AskAIAsync` uses the same protection when processing document content in RAG scenarios.

---

CRITICAL — follow these rules in every interaction:

1. **Async only**: All AI operations are `async Task` — always `await` them and make the calling method `async`.
2. **Provider selection**: Never hardcode a provider. Confirm the developer's preferred AI provider before generating connection code.
3. **Credentials**: Always use environment variables or configuration for endpoints and API keys. Never embed secrets in source code.
4. **NuGet packages**: Use exact packages from the Prerequisites table. Do not invent package names.
5. **Namespace imports**: Always include all `using` directives shown in examples. The most common are: `DevExpress.AIIntegration`, `DevExpress.AIIntegration.Docs`, `Microsoft.Extensions.AI`, `System.Globalization`.
6. **Version consistency**: All DevExpress packages must share the same version. Do not mix versions.
7. **PDF translate returns string**: `TranslateAsync` for PDF returns `Task` (translated text) — it does NOT modify the PDF in place. The developer must render the ret

…

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [DevExpress](https://github.com/DevExpress)
- **Source:** [DevExpress/agent-skills](https://github.com/DevExpress/agent-skills)
- **License:** MIT
- **Homepage:** https://www.devexpress.com

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-devexpress-agent-skills-devexpress-office-file-api-ai-powered-extensions
- Seller: https://agentstack.voostack.com/s/devexpress
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
