Skip to main content

Document.Unprotect() Method

Removes document protection.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v24.1.Core.dll

NuGet Packages: DevExpress.RichEdit.Core, DevExpress.Win.Navigation

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