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!
Ducaisoft
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!
Ducaisoft
You can use the following overload of Protect method:
Document doc = new Document("E:\\temp\\input.docx");
doc.Protect(ProtectionType.ReadOnly, "password");
doc.Save("E:\\temp\\19.2.docx");
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.