# docx-editor-document-protection

> Document editor with protection settings and restricted editing modes.

**Framework:** blazor  **Component:** DocxEditor  **Variant:** document-protection

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/blazor/docx-editor-document-protection.json
```

**Install Package(s)**

```bash
dotnet add package Syncfusion.Blazor.WordProcessor
```

**Notes**

- Syncfusion release: 2026 Volume 3 (v35.1.37)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/docx-editor-document-protection/DocxEditor.razor

```razor
@page "/document-editor/document-protection"
@namespace blazor.Components.Pages.DocumentProtection.DocumentProtection
@using System.Text.Json
@using Syncfusion.Blazor.Buttons;
@using Syncfusion.Blazor.DocumentEditor;
@using Syncfusion.Blazor.DropDowns;
@using Syncfusion.Blazor.Inputs;

<div class="control-section">
    <div class="content-wrapper">
        <div class="heading-section">
            <h5><b>User Permission</b></h5>
        </div>
        <div class="control-label"><b>Current User</b></div>
        <SfDropDownList TValue="string" TItem="string" @bind-Value="CurrentUser" DataSource="@Users" Placeholder="Select User"></SfDropDownList>
        <div class="control-label"><b>User Color</b></div>
        <SfColorPicker @bind-Value="UserColor"></SfColorPicker>
    </div>
    <SfDocumentEditorContainer @ref="_containerRef" Height="590px" CurrentUser="@CurrentUser" UserColor="@UserColor" DocumentEditorSettings="_settings">
        <DocumentEditorContainerEvents Created="OnCreated"></DocumentEditorContainerEvents>
    </SfDocumentEditorContainer>
</div>

@code {
    internal string CurrentUser { get; set; } = "user.one@example.com";
    internal string UserColor { get; set; } = "#b70f34";
    internal List<string> Users { get; set; } = new List<string> { "user.one@example.com", "user.two@example.com" };
    private SfDocumentEditorContainer? _containerRef;
    private DocumentEditorSettingsModel _settings = new DocumentEditorSettingsModel { ShowRuler = true };

    public async Task OnCreated(object args)
    {
        if (_containerRef?.DocumentEditor != null)
        {
            string text = "Pick a field on the left to insert a merge field at the cursor position.";

            var sfdt = new
            {
                sections = new[]
                {
                    new
                    {
                        blocks = new[]
                        {
                            new
                            {
                                inlines = new[]
                                {
                                    new { text }
                                }
                            }
                        },
                        headerFooter = new { },
                        sectionFormat = new
                        {
                            pageWidth = 612,
                            pageHeight = 792,
                            leftMargin = 72,
                            rightMargin = 72,
                            topMargin = 72,
                            bottomMargin = 72
                        }
                    }
                }
            };

            string json = JsonSerializer.Serialize(sfdt);
            await _containerRef.DocumentEditor.OpenAsync(json);
            // Lock the document so only the current user can make changes.
            await InvokeAsync(StateHasChanged);
        }
    }
}

```
