Protect your sensitive information and control document access with ease. The Syncfusion .NET Word Library (DocIO) empowers you to programmatically encrypt and decrypt Word documents in C# and restrict editing privileges, all without relying on Microsoft Word or interop dependencies.
Here is an example of how to encrypt a Word document in C# using the Syncfusion .NET Word Library (DocIO).
//Load an existing Word document.
using FileStream inputStream = new FileStream("Template.docx", FileMode.Open, FileAccess.Read);
using WordDocument document = new WordDocument(inputStream, FormatType.Docx);
//Encrypt the Word document with a password.
document.EncryptDocument("password");
//Save the Word document.
using FileStream outputStream = new FileStream("Sample.docx", FileMode.Create, FileAccess.Write);
document.Save(outputStream, FormatType.Docx);
Here is an example of how to decrypt a password-protected Word document in C# using the Syncfusion .NET Word Library (DocIO).
//Load an existing Word document with password.
using FileStream inputStream = new FileStream("Template.docx", FileMode.Open, FileAccess.Read);
using WordDocument document = new WordDocument(inputStream, FormatType.Docx, "password");
//Decrypt the Word document.
document.RemoveEncryption();
//Save the Word document.
using FileStream outputStream = new FileStream("Sample.docx", FileMode.Create, FileAccess.Write);
document.Save(outputStream, FormatType.Docx);
The .NET Word Library (DocIO) provides comprehensive options for restricting editing within Word documents programmatically in C#.
In this mode, users can view the document content but cannot make any edits, ensuring document integrity.
In this mode, users can add or modify comments in the document, but cannot change the actual content.
In this mode, form fields remain accessible while the Word document’s main content is protected.
In this mode, users can suggest changes but cannot directly edit existing text, enabling transparent review and feedback.
Greatness—it’s one thing to say you have it, but it means more when others recognize it. Syncfusion is proud to hold the following industry awards.