Document protection

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Editor MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-editor -- dnx GroupDocs.Editor.Mcp --yes
Folders, licensing and more →

The Password property, if set, enables document protection from opening by encrypting it with a specified password. However, almost all WordProcessing formats support document protection from writing, which is different from opening protection. Document protection, like document encoding, involves a password but also supports different levels of protection: some allow only read-only mode, while others allow editing form fields, adding comments, etc.

GroupDocs.Editor allows applying document protection through the Protection property in the WordProcessingSaveOptions class. By default, this property is set to NULL, meaning no protection is applied to the document.

The Protection property is of the type WordProcessingProtection. This class consists of two properties: Password and ProtectionType.

The WordProcessingProtection class has two constructors. The first constructor is parameterless and sets both class properties to their default values. If this constructor is used without modifying the properties, the protection will not be applied. The second constructor takes two parameters to set both properties directly.

The Password property sets the password for document protection. If the password is not provided, protection will not be applied, regardless of the ProtectionType value.

The ProtectionType property is of type WordProcessingProtectionType, which is an enum. This enum determines the level of protection. The default value is NoProtection, meaning no protection is applied. Other values include:

  1. AllowOnlyRevisions — User can only add revision marks to the document.
  2. AllowOnlyComments — User can only modify comments in the document.
  3. AllowOnlyFormFields — User can only enter data into the form fields in the document.
  4. ReadOnly — No changes are allowed to the document.

Important Notes

Both the Password and ProtectionType properties are interdependent. If a non-NULL and non-empty Password is provided, but the ProtectionType is set to NoProtection, then no protection will be applied. Conversely, if a ProtectionType like AllowOnlyFormFields is set but the Password is NULL or an empty string, the protection will not be applied either.