Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Document.Unprotect() Method

Removes document protection.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v24.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

View 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();
  }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Unprotect() method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also