We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to set opening password, modifying password and editing password respectively?

Hi, Support,

I have the question how to set password for opening , modifying or editing a document respectively. how to work it out?
By using SaveOption method, it seems only to set opening password for document?

Thanks for your help!



You can use the following overload of Protect method:

Document doc = new Document("E:\\temp\\input.docx");
doc.Protect(ProtectionType.ReadOnly, "password");

Also, in order to save document with encryption please use the following code snippet:

Document doc = new Document("E:\\Temp\\input.docx");

OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
saveOptions.Password = "myPassword";

doc.Save("E:\\Temp\\out.docx", saveOptions);

Hope, this helps.