I need to protect a specific section of a Word document. Can this be accomplished in the latest version of Aspose.Words?
Thanks for your inquiry. I am afraid, currently Aspose.Words does not support protection of selected ranges (partial protection of document). Your request has been linked to the appropriate feature. We will let you know once this feature is supported. We apologize for your inconvenience.
The feature ID is WORDSNET-1067.
However, You can use Section.ProtectedForForms property to protect section for forms. When a section is protected for forms, users can select and modify text only in form fields in Microsoft Word.
Following code snippet shows how to 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.ProtectedForForms = false; builder.Document.Save(MyDir + "Section.Protect Out.doc");