Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
248 changes: 230 additions & 18 deletions Document-Processing/Word/Word-Processor/angular/restrict-editing.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -225,18 +225,19 @@ The following example code illustrates how to write a Web API for restrict editi
[HttpPost]
[EnableCors("AllowAllOrigins")]
[Route("RestrictEditing")]
public string[] RestrictEditing([FromBody]CustomRestrictParameter param)
public string[] RestrictEditing([FromBody] CustomRestrictParameter param)
{
if (param.passwordBase64 == "" && param.passwordBase64 == null)
if (param.passwordBase64 == "" || param.passwordBase64 == null)
return null;
return WordDocument.ComputeHash(param.passwordBase64, param.saltBase64, param.spinCount);
return WordDocument.ComputeHash(param.passwordBase64, param.saltBase64, param.spinCount, param.algorithmSid);
}

public class CustomRestrictParameter
{
public string passwordBase64 { get; set; }
public string saltBase64 { get; set; }
public int spinCount { get; set; }
public string algorithmSid { get; set; }
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,16 @@ The following example code illustrates how to write a Web API for restrict editi
@CrossOrigin(origins = "*", allowedHeaders = "*")
@PostMapping("/api/wordeditor/RestrictEditing")
public String[] restrictEditing(@RequestBody CustomRestrictParameter param) throws Exception {
if (param.passwordBase64 == "" && param.passwordBase64 == null)
if (param.passwordBase64 == "" || param.passwordBase64 == null)
return null;
return WordProcessorHelper.computeHash(param.passwordBase64, param.saltBase64, param.spinCount);
return WordProcessorHelper.computeHash(param.passwordBase64, param.saltBase64, param.spinCount, param.algorithmSid);
}

public class CustomRestrictParameter {
public String passwordBase64;
public String saltBase64;
public int spinCount;
public String algorithmSid;
public String getPasswordBase64() {
return passwordBase64;
}
Expand All @@ -349,6 +350,9 @@ The following example code illustrates how to write a Web API for restrict editi
public int getSpinCount() {
return spinCount;
}
public String getAlgorithmSid() {
return algorithmSid;
}
public void setPasswordBase64(String value) {
passwordBase64= value;
}
Expand All @@ -358,6 +362,9 @@ The following example code illustrates how to write a Web API for restrict editi
public void setSpinCount(int value) {
spinCount= value;
}
public void setAlgorithmSid(String value) {
algorithmSid= value;
}
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,19 @@ The following example code illustrates how to write a Web API for restrict editi
[HttpPost]
[EnableCors("*", "*", "*")]
[Route("RestrictEditing")]
public string[] RestrictEditing([FromBody]CustomRestrictParameter param)
public string[] RestrictEditing([FromBody] CustomRestrictParameter param)
{
if (param.passwordBase64 == "" && param.passwordBase64 == null)
if (param.passwordBase64 == "" || param.passwordBase64 == null)
return null;
return Syncfusion.EJ2.DocumentEditor.WordDocument.ComputeHash(param.passwordBase64, param.saltBase64, param.spinCount);
return Syncfusion.EJ2.DocumentEditor.WordDocument.ComputeHash(param.passwordBase64, param.saltBase64, param.spinCount, param.algorithmSid);
}

public class CustomRestrictParameter
{
public string passwordBase64 { get; set; }
public string saltBase64 { get; set; }
public int spinCount { get; set; }
public string algorithmSid { get; set; }
}
```

Expand Down
184 changes: 171 additions & 13 deletions Document-Processing/Word/Word-Processor/asp-net-core/restrict-editing.md

Large diffs are not rendered by default.

184 changes: 171 additions & 13 deletions Document-Processing/Word/Word-Processor/asp-net-mvc/restrict-editing.md

Large diffs are not rendered by default.

134 changes: 126 additions & 8 deletions Document-Processing/Word/Word-Processor/blazor/restrict-editing.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
---
layout: post
title: Restrict editing in Blazor DocumentEditor Component | Syncfusion
description: Checkout and learn here all about Restrict editing in Syncfusion Blazor DocumentEditor component and more.
title: Restrict editing in Blazor DOCX Editor | Syncfusion
description: Learn how to enable Restrict Editing in the Blazor DOCX Editor to securely manage document access and control user modifications.
platform: document-processing
control: DocumentEditor
documentation: ug
---

# Restrict editing in Blazor DocumentEditor Component
# Restrict editing in Blazor DOCX Editor

This [Blazor Word Processor control](https://www.syncfusion.com/blazor-components/blazor-word-processor) (DocumentEditor) provides 2 types of restriction for editing:
* Read-only: Allows all the users to view the document contents but not make changes to it.
* Allows changes to certain portion of the document: Allows the users to edit to certain portion of the document.
Syncfusion® [Blazor Word Processor control](https://www.syncfusion.com/blazor-components/blazor-word-processor) (Document Editor) provides support for restricting editing within a document. It enables control over how and where content can be modified. This helps limit editing so only specific sections of the document can be changed.

## Read only
## Read only mode

Document Editor supports protecting a document in read-only mode, where users can only view the content without making changes.

The following code example shows how to restrict or protect editing for the entire content (show as read-only).

Expand All @@ -33,6 +33,96 @@ The following code example shows how to restrict or protect editing for the enti
}
```

## Form filling mode

Document Editor supports protecting a document with form-filling restrictions, allowing users to edit only form fields.

The following code example illustrates how to enforce form-filling protection in the Document Editor.

```cshtml
@using Syncfusion.Blazor.DocumentEditor

<button @onclick="EnforceProtection">Enforce Protection</button>
<button @onclick="StopProtection">Stop Protection</button>
<SfDocumentEditorContainer @ref="container" EnableToolbar=true></SfDocumentEditorContainer>

@code {
SfDocumentEditorContainer container;

public async void EnforceProtection(object args)
{
// enforce form fields only protection
await container.DocumentEditor.Editor.EnforceProtectionAsync("123", ProtectionType.FormFieldsOnly);
}

public async void StopProtection(object args)
{
// stop the document protection
await container.DocumentEditor.Editor.StopProtectionAsync("123");
}
}
```

## Comments only mode

Document Editor supports protecting a document in comments-only mode, allowing users to add or edit comments only.

The following code example illustrates how to enforce and remove comments-only protection in the Document Editor.

```cshtml
@using Syncfusion.Blazor.DocumentEditor

<button @onclick="EnforceProtection">Enforce Protection</button>
<button @onclick="StopProtection">Stop Protection</button>
<SfDocumentEditorContainer @ref="container" EnableToolbar=true></SfDocumentEditorContainer>

@code {
SfDocumentEditorContainer container;

public async void EnforceProtection(object args)
{
// enforce comments only protection
await container.DocumentEditor.Editor.EnforceProtectionAsync("123", ProtectionType.CommentsOnly);
}

public async void StopProtection(object args)
{
// stop the document protection
await container.DocumentEditor.Editor.StopProtectionAsync("123");
}
}
```

## Track changes only mode

Document Editor supports protecting a document in revisions-only mode, allowing users to view the document and make corrections while tracking all changes. Users cannot accept or reject tracked changes; only the author can review and finalize them later.

The following code example illustrates how to enforce and remove revisions-only protection in the Document Editor.

```cshtml
@using Syncfusion.Blazor.DocumentEditor

<button @onclick="EnforceProtection">Enforce Protection</button>
<button @onclick="StopProtection">Stop Protection</button>
<SfDocumentEditorContainer @ref="container" EnableToolbar=true></SfDocumentEditorContainer>

@code {
SfDocumentEditorContainer container;

public async void EnforceProtection(object args)
{
// enforce revisions only protection
await container.DocumentEditor.Editor.EnforceProtectionAsync("123", ProtectionType.RevisionsOnly);
}

public async void StopProtection(object args)
{
// stop the document protection
await container.DocumentEditor.Editor.StopProtectionAsync("123");
}
}
```

## Allows changes to certain portion of the document

Also, at some situations, you might need to allow changes for a certain portion of the document alone. Microsoft Word allows you to [make changes to parts of a Word document](https://support.microsoft.com/en-us/office/allow-changes-to-parts-of-a-protected-document-187ed01c-8795-43e1-9fd0-c9fca419dadf?ui=en-us&rs=en-us&ad=us). Likewise, the document editor control allows the users to make changes to certain parts of a document using similar user interface.
Expand All @@ -41,6 +131,34 @@ Also, at some situations, you might need to allow changes for a certain portion

![Enabling Restrict Editing in Blazor DocumentEditor](./images/blazor-document-editor-enable-edit-restriction.png)

## Set current user

The `CurrentUser` property can be used to authorize the current document user by name, email, or user group.

The following code example demonstrates how to set the CurrentUser.

```cshtml
container.DocumentEditor.CurrentUser = "engineer@mycompany.com";
```

## Highlighting the text area

The `UserColor` property can be used to highlight the editable region of the current user.

The following code example demonstrates how to set the UserColor.

```cshtml
container.DocumentEditor.UserColor = "#fff000";
```

The `HighlightEditableRanges` property can be used to toggle the highlighting of editable regions.

The following code example demonstrates how to enable or disable editable region highlighting.

```cshtml
container.DocumentEditor.DocumentEditorSettings.HighlightEditableRanges = true;
```

## Online Demo

Explore how to restrict editing and protect Word documents using the Blazor Document Editor in this live demo [here](https://document.syncfusion.com/demos/docx-editor/blazor-server/document-editor/document-protection?theme=fluent2).
Explore how to restrict editing and protect Word documents using the Blazor Document Editor in this live demo [here](https://document.syncfusion.com/demos/docx-editor/blazor-server/document-editor/document-protection?theme=fluent2).
Loading