Novacode.DocX.AddProtection C# (CSharp) Method

AddProtection() public method

Add editing protection to this document.
public AddProtection ( EditRestrictions er ) : void
er EditRestrictions The type of protection to add to this document.
return void
        public void AddProtection(EditRestrictions er)
        {
            // Call remove protection before adding a new protection element.
            RemoveProtection();

            if (er == EditRestrictions.none)
                return;

            XElement documentProtection = new XElement(XName.Get("documentProtection", w.NamespaceName));
            documentProtection.Add(new XAttribute(XName.Get("edit", w.NamespaceName), er.ToString()));
            documentProtection.Add(new XAttribute(XName.Get("enforcement", w.NamespaceName), "1"));

            settings.Root.AddFirst(documentProtection);
        }

Same methods

DocX::AddProtection ( EditRestrictions er, string strPassword ) : void