public void Protect()
{
//ExStart
//ExFor:Document.Protect(ProtectionType)
//ExFor:ProtectionType
//ExFor:Section.ProtectedForForms
//ExSummary:Protects a section so only editing in form fields is possible.
// Create a blank document
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[0].ProtectedForForms = false;
builder.Document.Save(MyDir + @"\Artifacts\Section.Protect.doc");
//ExEnd
}