[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Collapse]Office File API
  Demo Application
  Redistribution and Deployment
 [Expand]Spreadsheet Document API
 [Collapse]Word Processing Document API
   Getting Started
  [Expand]WordProcessing Document
  [Expand]Merge and Split Documents
   Import and Export
  [Expand]Fields
   Text Formatting
  [Expand]Mail Merge
   Printing
   Export to PDF
   Document Protection
   HTML Tag Support
  [Expand]Examples
 [Expand]PDF Document API
 [Expand]Excel Export Library
 [Expand]Snap Report API
 [Expand]Zip Compression and Archive API
 [Expand]Barcode Generation API
 [Expand]Unit Conversion API
 [Expand]API Reference
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Document Protection

Expanded Protect the Document from Editing

You can keep anyone from making changes in a document by enabling the document protection. Call the Document.Protect method to protect a document from editing using a given password and protection type (read-only or allow comments only). The default protection type is DocumentProtectionType.ReadOnly. The Document.IsDocumentProtected property indicates whether the document is protected.

Use the Document.Unprotect method to disable protection. Note that it unlocks the document without prompting the user for a password. To prompt the user with a password, execute the UnprotectDocumentCommand command.

Note

The RichEditDocumentServer protection affects only the document modification. The RichEditDocumentServer protection protects the document only against modifications. The document is opened without prompting for a password.

Expanded Grant Permission to Users

You can allow certain users to edit parts of a protected document by creating Range Permissions as described in the steps below.

  1. Call the SubDocument.BeginUpdateRangePermissions method to access the document range permissions collection.
  2. Create a new RangePermission object using the RangePermissionCollection.CreateRangePermission method.
  3. Utilize the RangePermission.UserName or RangePermission.Group property to specify the specific user or group of users that are allowed to edit the document range.

    Make sure that the property value is equal to the target user's credentials.

  4. Add the created object to the RangePermissionCollection.
  5. Finalize the modification by calling the SubDocument.EndUpdateRangePermissions method.
  6. Enable document protection. When the protection is enabled, ranges without editing permissions are read-only.

Is this topic helpful?​​​​​​​