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.

Regards,
Senthil

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.
Document dstDoc = new Document();
dstDoc.RemoveAllChildren();
PageNumberFinder finder = new PageNumberFinder(doc);
// Split nodes which are found across pages.
finder.SplitNodesAcrossPages(true);
// Copy all content including headers and footers from the specified pages into the destination document.
ArrayList pageSections = finder.RetrieveAllNodesOnPage(3, 5, NodeType.Section);

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,