Skip to main content
All docs
V25.2
  • IAIDocProcessingService.ProofreadAsync(RichEditDocumentServer, CultureInfo, CancellationToken) Method

    Reviews the text for spelling, grammar, punctuation, and style errors.

    Namespace: DevExpress.AIIntegration.Docs

    Assembly: DevExpress.AIIntegration.Docs.v25.2.dll

    NuGet Package: DevExpress.AIIntegration.Docs

    Declaration

    Task ProofreadAsync(
        RichEditDocumentServer wordProcessor,
        CultureInfo culture,
        CancellationToken cancellationToken = default(CancellationToken)
    )

    Parameters

    Name Type Description
    wordProcessor RichEditDocumentServer

    The RichEditDocumentServer instance which text should be reviewed.

    culture CultureInfo

    An object that specifies culture settings applied during proofreading.

    Optional Parameters

    Name Type Default Description
    cancellationToken CancellationToken null

    The token that cancels the task.

    Returns

    Type Description
    Task

    The response that contains AI-generated text.

    Example

    How to: Proofread a Word Document

    The following code snippet proofreads an entire document. Code to proofread only the second paragraph is included as commented code.

    using DevExpress.AIIntegration.Docs;
    using DevExpress.XtraRichEdit;
    using DevExpress.XtraRichEdit.API.Native;
    using System.Diagnostics;
    
    var docProcessingService = defaultAIExtensionsContainer.CreateAIDocProcessingService();
    
    using (var wordProcessor = new RichEditDocumentServer())
    {
        // Load source document (ensure file exists in relative Documents folder)
        wordProcessor.LoadDocument("Documents/FirstLookShortened.docx");
    
        // Proofread entire document (culture en-US)
        await docProcessingService.ProofreadAsync(wordProcessor, new System.Globalization.CultureInfo("en-US"));
    
        // Proofread a single paragraph
        // Paragraph paragraph = wordProcessor.Document.Paragraphs[1];
        // await docProcessingService.ProofreadAsync(paragraph.Range, new System.Globalization.CultureInfo("en-US"));
    
        // Prepare output directory & file path
        string targetDir = @"C:\Test Documents";
        Directory.CreateDirectory(targetDir); // Safe if already exists
        string outputPath = Path.Combine(targetDir, "Proofread.docx");
    
        // Save the proofread document
        using (FileStream outputStream = new FileStream(outputPath, FileMode.Create, FileAccess.Write))
        {
            wordProcessor.SaveDocument(outputStream, DocumentFormat.OpenXml);
        }
    }
    
    See Also