Restrict Editing
Restrict editing enables you to fully or partially protect a Word document from unintentional changes with an optional password. If the password is not specified, any user can stop enforcing the protection from the Word application.
Note, with GemBox.Document you can modify a whole Word file even if it allows changes to just parts of a protected document.
The following example shows how you can start enforcing editing restriction protection using the DocumentProtection
class.
using GemBox.Document;
class Program
{
static void Main()
{
// If using the Professional version, put your serial key below.
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
var document = DocumentModel.Load("%InputFileName%");
EditingRestrictionType restriction = %EditingRestrictionType%;
string password = "%Password%";
document.Protection.StartEnforcingProtection(restriction, password);
document.Save("Restrict Editing.docx");
}
}
Imports GemBox.Document
Module Program
Sub Main()
' If using the Professional version, put your serial key below.
ComponentInfo.SetLicense("FREE-LIMITED-KEY")
Dim document = DocumentModel.Load("%InputFileName%")
Dim restriction As EditingRestrictionType = %EditingRestrictionType%
Dim password As String = "%Password%"
document.Protection.StartEnforcingProtection(restriction, password)
document.Save("Restrict Editing.docx")
End Sub
End Module