Skip to main content
A newer version of this page is available. .

DxRichEdit.DocumentFormat Property

Specifies the format in which the DocumentContent property stores content of an open document.

Namespace: DevExpress.Blazor.RichEdit

Assembly: DevExpress.Blazor.RichEdit.v21.2.dll

NuGet Package: DevExpress.Blazor.RichEdit

Declaration

[Parameter]
public DocumentFormat DocumentFormat { get; set; }

Property Value

Type Description
DocumentFormat

A document format.

Available values:

Name Description
OpenXml

Office Open XML format (DOCX).

Rtf

Rich text format.

PlainText

Plain text format.

Remarks

If you do not assign a document’s format value to the DocumentFormat property before you open the document, the Rich Text Editor cannot parse the document correctly.

The Rich Text Editor does not update the DocumentContent property value automatically when you change the DocumentFormat property value. Call the SaveDocumentAsync() method to raise the DocumentContentChanged event and convert the DocumentContent property value to another format.

The example below demonstrates how to open an RTF document:

<DxRichEdit DocumentFormat="DocumentFormat.Rtf" @bind-DocumentContent="@documentContent"/>

@code {
    byte[] documentContent;
    string filePath = "C:\\Users\\Public\\annual-report.rtf";

    protected override async Task OnInitializedAsync() {
    /* Surround the code that contains an asynchronous operation with a try-catch block to handle
    the OperationCanceledException. This exception is thrown when an asynchronous operation is cancelled. */
        try {
            documentContent = await File.ReadAllBytesAsync(filePath);
            await base.OnInitializedAsync();
        }
        catch (OperationCanceledException e) {
            Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
        }
    }
}
See Also