Back to Devexpress

IAIDocProcessingService.ProofreadAsync(Presentation, CultureInfo, CancellationToken) Method

officefileapi-devexpress-dot-aiintegration-dot-docs-dot-iaidocprocessingservice-dot-proofreadasync-x28-devexpress-dot-docs-dot-presentation-dot-presentation-system-dot-globalization-dot-cultureinfo-system-dot-threading-dot-cancellationtoken-x29.md

latest5.7 KB
Original Source

IAIDocProcessingService.ProofreadAsync(Presentation, 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

csharp
Task ProofreadAsync(
    Presentation presentation,
    CultureInfo culture,
    CancellationToken cancellationToken = default(CancellationToken)
)
vb
Function ProofreadAsync(
    presentation As Presentation,
    culture As CultureInfo,
    cancellationToken As CancellationToken = Nothing
) As Task

Parameters

NameTypeDescription
presentationPresentation

The Presentation instance which text should be reviewed.

| | culture | CultureInfo |

An object that specifies culture settings applied during proofreading.

|

Optional Parameters

NameTypeDefaultDescription
cancellationTokenCancellationTokennull

The token that cancels the task.

|

Returns

TypeDescription
Task

The response that contains AI-generated text.

|

Example

How to: Proofread a Presentation

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

csharp
using DevExpress.AIIntegration;
using DevExpress.AIIntegration.Docs;
using DevExpress.Docs.Presentation;

var docProcessingService = defaultAIExtensionsContainer.CreateAIDocProcessingService();

using (var presentation = new Presentation(File.ReadAllBytes("Documents/Presentation.pptx")))  
{
    // Proofread entire document (culture en-US)
    await docProcessingService.ProofreadAsync(presentation, new System.Globalization.CultureInfo("en-US"));

    // Proofread a single slide (e.g., slide 2)
    // Slide slide = presentation.Slides[1];
    // await docProcessingService.ProofreadAsync(slide, 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.pptx");

    // Save the proofread presentation
    using (FileStream outputStream = new FileStream(outputPath, FileMode.Create, FileAccess.Write))
    {
        presentation.SaveDocument(outputStream, DocumentFormat.Pptx);
    }
}
vb
Imports DevExpress.AIIntegration
Imports DevExpress.AIIntegration.Docs
Imports DevExpress.Docs.Presentation
Imports System.Globalization
Imports System.IO
Imports System.Threading.Tasks

Dim docProcessingService = defaultAIExtensionsContainer.CreateAIDocProcessingService()

Using presentation = New Presentation(File.ReadAllBytes("Documents/Presentation.pptx"))
    ' Proofread entire document (culture en-US)
    Await docProcessingService.ProofreadAsync(presentation, New CultureInfo("en-US"))

    ' Proofread a single slide (e.g., slide 2)
    ' Dim slide As Slide = presentation.Slides(1)
    ' Await docProcessingService.ProofreadAsync(slide, New CultureInfo("en-US"))

    ' Prepare output directory & file path
    Dim targetDir As String = "C:\Test Documents"
    Directory.CreateDirectory(targetDir) ' Safe if already exists
    Dim outputPath As String = Path.Combine(targetDir, "Proofread.pptx")

    ' Save the proofread presentation
    Using outputStream As New FileStream(outputPath, FileMode.Create, FileAccess.Write)
        presentation.SaveDocument(outputStream, DocumentFormat.Pptx)
    End Using
End Using

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ProofreadAsync(Presentation, CultureInfo, CancellationToken) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

office-file-api-ai-implementation/CS/Controllers/ProofreadController.cs#L84

csharp
case PresentationPart.WholePresentation:
    await docProcessingService.ProofreadAsync(presentation, cultureSettings);
    break;

See Also

IAIDocProcessingService Interface

IAIDocProcessingService Members

DevExpress.AIIntegration.Docs Namespace