public void Protect( ProtectionType type )
Public Sub Protect ( type As ProtectionType )
public: void Protect( ProtectionType type )
member Protect : type : ProtectionType -> unit
When a document is protected, the user can make only limited changes, such as adding annotations, making revisions, or completing a form.
When you protect a document, and the document already has a protection password, the existing protection password is not changed.
When you protect a document, and the document does not have a protection password, this method assigns a random password that makes it impossible to unprotect the document in Microsoft Word, but you still can unprotect the document in Aspose.Words as it does not require a password when unprotecting.
Document doc = new Document(); // Insert two sections with some text DocumentBuilder builder = new DocumentBuilder(doc); builder.Writeln("Section 1. Unprotected."); builder.InsertBreak(BreakType.SectionBreakContinuous); builder.Writeln("Section 2. Protected."); // Section protection only works when document protection is turned and only editing in form fields is allowed doc.Protect(ProtectionType.AllowOnlyFormFields); // By default, all sections are protected, but we can selectively turn protection off doc.Sections.ProtectedForForms = false; doc.Save(ArtifactsDir + "Section.Protect.docx");