Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

Document.Unprotect() Method

Removes document protection.

Namespace: DevExpress.XtraRichEdit.API.Native

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

NuGet Package: DevExpress.RichEdit.Core

Declaration

void Unprotect()

Remarks

The Unprotect method removes document protection without prompting or password entry. To prompt end-users with a password, execute the UnprotectDocumentCommand command.

The Document.IsDocumentProtected property indicates whether the document is protected.

Example

using (var wordProcessor = new RichEditDocumentSever())
{
  wordProcessor.LoadDocument("Documents//Grimm_Protected.docx");
  Document document = wordProcessor.Document;

  if (document.IsDocumentProtected == true)
  {
    // Unprotect the document
    document.Unprotect();

    // Insert a comment indicating that the document can be edited
    document.Comments.Create(document.Paragraphs[0].Range,"Admin");
    SubDocument commentDocument = document.Comments[0].BeginUpdate();
    commentDocument.InsertText(commentDocument.CreatePosition(0),
    "Document is unprotected. You can modify the document.");
    commentDocument.EndUpdate();
  }
}
See Also