Back to Devexpress

Summarize and Translate Reports in the WinForms Document Viewer

xtrareports-405260-ai-powered-functionality-desktop-reporting-summarize-translate-in-winforms-document-viewer.md

latest8.5 KB
Original Source

Summarize and Translate Reports in the WinForms Document Viewer

  • Nov 24, 2025
  • 5 minutes to read

Follow instructions in this article to integrate AI-powered Summarize and Translate commands into the WinForms Document Viewer.

SummarizeUses generative AI to summarize report content and displays core insights associated with this report.TranslateUses AI services to translate report content to another language.

Tip

You can also integrate the Translate Inline command that allows you to translate reports when previewing a report. Refer to the following help topic for details: Inline Report Translation in the WinForms Document Viewer.

Activate AI Assistant

Install NuGet Packages

Install the following NuGet packages:

The following tutorial uses Azure OpenAI. Refer to the requirements section for information about NuGet packages required for other supported AI services.

Register AI Client

The following code snippet registers an Azure OpenAI client at application startup:

csharp
using Azure.AI.OpenAI;
using DevExpress.AIIntegration;
using Microsoft.Extensions.AI;
using System.ClientModel;

internal static class Program {
    static string AzureOpenAIEndpoint { get { return "AZURE_OPENAI_ENDPOINT"; } }
    static string AzureOpenAIKey { get { return "AZURE_OPENAI_APIKEY"; } }
    static string DeploymentName { get { return "MODEL_NAME"; } } // For example, gpt-4.1.
    [STAThread]
    static void Main(){
        IChatClient client = new AzureOpenAIClient(
            new Uri(AzureOpenAIEndpoint),
            new ApiKeyCredential(AzureOpenAIKey))
                .GetChatClient(DeploymentName).AsIChatClient(); 
        AIExtensionsContainerDesktop.Default.RegisterChatClient(client);
        ApplicationConfiguration.Initialize();
        Application.Run(new Form1());
    }
}
vb
Imports Azure.AI.OpenAI
Imports DevExpress.AIIntegration
Imports Microsoft.Extensions.AI
Imports System.ClientModel

Friend Module Program
    Private ReadOnly Property AzureOpenAIEndpoint() As String
        Get
            Return "AZURE_OPENAI_ENDPOINT"
        End Get
    End Property
    Private ReadOnly Property AzureOpenAIKey() As String
        Get
            Return "AZURE_OPENAI_APIKEY"
        End Get
    End Property
    Private ReadOnly Property DeploymentName() As String
        Get
            Return "MODEL_NAME"
        End Get
    End Property
        <STAThread>
        Sub Main()
        Dim client As IChatClient = (New AzureOpenAIClient(New Uri(AzureOpenAIEndpoint), New ApiKeyCredential(AzureOpenAIKey))).GetChatClient(DeploymentName).AsIChatClient()
        AIExtensionsContainerDesktop.Default.RegisterChatClient(client)
        ApplicationConfiguration.Initialize()
        Application.Run(New Form1())
        End Sub
End Module

Tip

How to Register OpenAI, Azure OpenAI, Ollama, and Semantic Kernel Clients.

Add Document Viewer

  1. Drop the DocumentViewer component from the Toolbox onto a Form.

  2. Create a Ribbon or Standard Toolbar to allow users to invoke the context menu with behavior commands in the Document Viewer.

  3. Specify the Document Source option. Use an object that supplies a document to the Document Viewer.

Create and Configure AI Assistant Behaviors

Follow the steps below to attach a behavior to the Document Viewer control at design time:

  1. Drop the BehaviorManager component from the Toolbox onto a Form.

  2. (For .NET Framework Projects) Use the Register AI-Powered Behaviors option in the BehaviorManager’s smart tag menu to add the “AI-Powered Behaviors” submenu with report behaviors to BehaviorManager.

  3. Use the Edit Behaviors option in the BehaviorManager’s smart tag menu to access the behavior collection.

  4. Add Translate and Summarize behaviors and configure their settings:

Create and Configure AI Assistant Behaviors at Runtime

The following code activates Summarize and Translate commands in two steps:

csharp
using DevExpress.AIIntegration;
using DevExpress.AIIntegration.WinForms;
// ...
public partial class Form1 : Form {
    public Form1() {
        InitializeComponent();
            behaviorManager1.Attach<DocumentSummarizeBehavior>(documentViewer1, behavior => {
                behavior.Properties.SummarizationMode = SummarizationMode.Extractive;
            });
            behaviorManager1.Attach<DocumentTranslateBehavior>(documentViewer1, behavior => {
                behavior.Properties.Languages = new LanguageInfo[] {
                    new LanguageInfo("de-DE"),
                    new LanguageInfo("es-ES")
                };
            });
    }
}
vb
Imports DevExpress.AIIntegration
Imports DevExpress.AIIntegration.WinForms
' ...
Partial Public Class Form1
    Inherits Form

    Public Sub New()
        InitializeComponent()
            behaviorManager1.Attach(Of DocumentSummarizeBehavior)(documentViewer1, Sub(behavior)
                behavior.Properties.SummarizationMode = SummarizationMode.Extractive
            End Sub)
            behaviorManager1.Attach(Of DocumentTranslateBehavior)(documentViewer1, Sub(behavior)
                behavior.Properties.Languages = New LanguageInfo() {
                    New LanguageInfo("de-DE"),
                    New LanguageInfo("es-ES")
                }
            End Sub)
    End Sub
End Class

Note

Call the BehaviorInitializer.Initialize() method at application startup if your project targets the .NET Framework and you create AI-powered behaviors in code. Otherwise, an exception is thrown.

csharp
internal static class Program {
    [STAThread]
    static void Main() {
        //...
        // The Initialize() method forcibly initializes the behavior manager in .NET Framework apps.
        DevExpress.AIIntegration.WinForms.Reporting.BehaviorInitializer.Initialize();
        Application.Run(new Form1());
    }
}

Use Translate Command

You can access the Translate command in the AI context menu of WinForms Document Viewer.

Right-click an opened report or selected report content. Select Translate from the AI Assistant submenu.

A dialog appears. Specify the input text range (selected content, document page, or entire document) and target language. Click “Translate” to generate and display a translation.

Click the copy icon to copy operation output.

Use Summarize Command

You can access the Summarize command in the AI context menu of WinForms Document Viewer.

Right-click an open report or selected report content. Select Summarize from the AI Assistant submenu.

A dialog appears. Specify the input text range for summarization (selected content, document page, or entire document). Click “Summarize” to display the summary.

Click the copy icon to copy operation output.