Hi,
I would like to know how I can set a password for a document so that the document can’t be opened without the password.
regards,
Devid.
Hi,
I would like to know how I can set a password for a document so that the document can’t be opened without the password.
regards,
Devid.
Hi Devid,
Thanks for your inquiry. Please use the following code snippet for your requirement and read following documentation links for your kind reference.
https://reference.aspose.com/words/net/aspose.words.saving/docsaveoptions
https://reference.aspose.com/words/net/aspose.words.saving/ooxmlsaveoptions
Document doc = new Document();
DocSaveOptions options = new DocSaveOptions(SaveFormat.Doc);
options.Password = "test";
doc.Protect(ProtectionType.ReadOnly, "passoword");
doc.Save(MyDir + "AsposeOut.doc", options);
Document doc = new Document();
OoxmlSaveOptions options = new OoxmlSaveOptions(SaveFormat.Docx);
options.Password = "test";
doc.Protect(ProtectionType.ReadOnly, "passoword");
doc.Save(MyDir + "AsposeOut.docx", options);
Please let us know if you have any more queries.
Hi tahir.manzoor,
Thanks a lot for your help, I solved my problem by using the code you suggested.
Regards,
Devid
Hi Devid,
Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.