Document.Unprotect() Method
Removes document protection.
Namespace: DevExpress.XtraRichEdit.API.Native
Assembly: DevExpress.RichEdit.v21.2.Core.dll
NuGet Package: DevExpress.RichEdit.Core
Declaration
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