| name | devexpress-office-file-api-ai-powered-extensions |
| description | 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 programmatically, or proofreading documents with AI. Also use when someone mentions "DevExpress AI", "AIIntegration.Docs", "AIDocProcessingService", "proofread Word document", "translate PDF", "AI document processing .NET", or asks about AI-powered document automation with DevExpress. Requires DevExpress v25.2+. |
| metadata | {"author":"DevExpress","version":26.1,"source-commit":"d4a70c0b5f39f3c991dd5ee8fa51f2d413ef26b6"} |
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)
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
- Target framework: .NET 8+ or .NET Framework 4.7.2?
- New or existing project?: Creating new or adding to an existing one?
- Hosting model: Console app, ASP.NET Core, Blazor, or other?
AI Extensions-Specific Questions
- AI provider: Azure OpenAI / OpenAI / Google Gemini / Ollama / ONNX / AI Foundry Local / other
IChatClient?
- Document type: Word (.docx) / PDF / PowerPoint (.pptx)?
- Operation scope: Entire document, or a specific section (paragraph, page range, slide range, coordinate region)?
- 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
using DevExpress.AIIntegration;
using DevExpress.AIIntegration.Docs;
using Microsoft.Extensions.AI;
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();
AIExtensionsContainerDefault container =
AIExtensionsContainerConsole.CreateDefaultAIExtensionContainer(client);
IAIDocProcessingService docService = container.CreateAIDocProcessingService();
Documentation & Navigation Guide
Getting Started
Refer to 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
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
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
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:
using DevExpress.AIIntegration;
using DevExpress.AIIntegration.Docs;
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
using Microsoft.Extensions.AI;
using System.Globalization;
string endpoint = "YOUR_AZURE_OPENAI_ENDPOINT";
string apiKey = "YOUR_AZURE_OPENAI_KEY";
string model = "gpt-4o-mini";
IChatClient client = new Azure.AI.OpenAI.AzureOpenAIClient(
new Uri(endpoint),
new System.ClientModel.ApiKeyCredential(apiKey))
.GetChatClient(model)
.AsIChatClient();
AIExtensionsContainerDefault container =
AIExtensionsContainerConsole.CreateDefaultAIExtensionContainer(client);
IAIDocProcessingService docService = container.CreateAIDocProcessingService();
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<string>) |
TranslateAsync(PdfDocumentProcessor, PdfDocumentArea, CultureInfo, CancellationToken) | Translate PDF region (returns Task<string>) |
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)
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)
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
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"));
pdf.SaveDocument("output.pdf");
Register in ASP.NET Core / Blazor
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:
- Async only: All AI operations are
async Task — always await them and make the calling method async.
- Provider selection: Never hardcode a provider. Confirm the developer's preferred AI provider before generating connection code.
- Credentials: Always use environment variables or configuration for endpoints and API keys. Never embed secrets in source code.
- NuGet packages: Use exact packages from the Prerequisites table. Do not invent package names.
- Namespace imports: Always include all
using directives shown in examples. The most common are: DevExpress.AIIntegration, DevExpress.AIIntegration.Docs, Microsoft.Extensions.AI, System.Globalization.
- Version consistency: All DevExpress packages must share the same version. Do not mix versions.
- PDF translate returns string:
TranslateAsync for PDF returns Task<string> (translated text) — it does NOT modify the PDF in place. The developer must render the returned text onto the document manually.
- Word/Presentation translate is in-place:
TranslateAsync for DocumentRange, Presentation, and Slide modifies the document in-place and returns Task.
- Framework detection: Check .csproj for target framework. AI extensions require .NET 8+ or .NET Framework 4.7.2.
- Build verification: After making changes, verify the project builds with
dotnet build.
Using DevExpress Documentation MCP
If the DxDocs MCP server is available, use it to supplement this skill:
- Search: Use
devexpress_docs_search with technology "AI-powered Extensions" or "AIIntegration.Docs" and your question.
- Fetch: Use
devexpress_docs_get_content with a documentation URL to get full article content.
When to use MCP vs. built-in references:
- Built-in references: Getting started, common patterns, key method signatures, troubleshooting.
- MCP search: Advanced RAG configuration (
RagOptions), Semantic Kernel connector setup, ONNX/AI Foundry Local setup, or features not covered here.
- Always MCP for: Exact overload signatures for edge-case scenarios, or when the developer reports a method does not exist.
Next Steps
Start with Getting Started to install packages and register your first AI provider. Then consult the document-type reference that matches your scenario.