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

Free Support Forum - aspose.com

Encrypt Word document with Passoword

Dear Team,

I would like to set a password for word document file which will prompt the user for password whenever the file is opened. Without a password, the file should not be opened.

Can we accomplish this using Aspose.Words component ? if yes please let me know how.


Hi Senthil,

Thanks for your inquiry. I think, you can use DocSaveOptions.Password and OoxmlSaveOptions.Password properties to achieve this. Please let me know if I can be of any further assistance.

Best regards,

Hi Awais,

Thanks for the details. I’m able to encrypt the document with password now.

Is it possible to extract the text from a specific page using Aspose.Words ? If yes could you please help me with an example.

Hi Senthil,

Thanks for your inquiry. Yes, this is possible, you can achieve this by using the utility methods available in the attached ‘PageNumberFinder’ class. For example, you can use the code like below to extract pages to an external document.

Document doc = new Document(“Document.docx”);

// Set up the document which pages will be copied to. Remove the empty section. <o:p></o:p>

Document dstDoc = new Document();<o:p></o:p>


PageNumberFinder finder = new PageNumberFinder(doc);<o:p></o:p>

// Split nodes which are found across pages.<o:p></o:p>


// Copy all content including headers and footers from the specified pages into the destination document.

ArrayList pageSections = finder.RetrieveAllNodesOnPage(3, 5, NodeType.Section);<o:p></o:p>

foreach (Section section in pageSections)

dstDoc.AppendChild(dstDoc.ImportNode(section, true));

dstDoc.Save(dataDir + “Document Out.docx”);

I hope, this helps.

Best regards,

Hi Awais,

Thanks a lot for the info. I will check and come back to you if required.

Hi Senthil,

Sure, please let us know any time you have any further queries. We are always glad to help you.

Best regards,