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

Free Support Forum - aspose.com

Searching a HTML preview of a Word document

We have built a Microsoft Word Add-in that allows a user to search and find documents from his company's SharePoint. Once the search results are displayed, the user can select one of the search results and view a preview of the document (without having to open the whole doc).

We are using Aspose.Words to render an HTML preview of the Word document via an Internet Explorer pop-up.

The requirement
We want to allow users to search a previewed document in a similar manner to using Word's search function (http://bit.ly/2pxc2C7). The user must be able to search for terms and view a list of results. If possible the user should be able to also navigate thru each result, one-by-one.

Currently it's possible to get a find function by pressing ctrl-f. A basic find tool pops up (http://bit.ly/2oqNw6l), however it doesn't list search results like Word's search functionality.

Additionally we'd like to present this search functionality to the user from the beginning of the preview. We can't assume that users will know to hit ctrl-f to be able to search the preview.

The request
1. Is it possible search and display results as i described?
2. Is it possible to display this search functionality from the get go?

Hi there,

Thanks for your inquiry. Aspose.Words for .NET is just a class library and with it you can programmatically generate, modify, convert, render and print documents without utilizing Microsoft Word®. So, it does not offer any UI or web control to view/perform document processing tasks.

However, you can achieve your requirements using Aspose.Words. In your case we suggest you following solution.

1) Find and highlight the text.
2) Add bookmark to matched text.
3) Iterate through all bookmarks.
4) Get the page numbers of bookmarks using LayoutCollector.GetEndPageIndex method. Pass BookmarkStart node to this method to get the page number.
5) Save the document's page to image that have the specific bookmark.
6) Display the image in the browser. You may save the specific page to HtmlFixed file format and display it in browser.

Hope this helps you.