Skip to main content
All docs
V26.1
  • 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.v26.1.dll

    NuGet Package: DevExpress.Blazor.RichEdit

    Declaration

    [DefaultValue(DocumentFormat.OpenXml)]
    [Parameter]
    public DocumentFormat DocumentFormat { get; set; }

    Property Value

    Type Default Description
    DocumentFormat OpenXml

    A document format.

    Available values:

    Name Description
    OpenXml

    Office Open XML format (DOCX).

    Rtf

    Rich text format.

    PlainText

    Plain text format.

    Html

    HTML 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(CancellationToken) method to raise the DocumentContentChanged event and convert the DocumentContent property value to another format.

    The following code snippet opens 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 canceled. */
            try {
                documentContent = await File.ReadAllBytesAsync(filePath);
                await base.OnInitializedAsync();
            }
            catch (OperationCanceledException e) {
                Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
            }
        }
    }
    
    See Also