in reply to how to open and highlight text

I'm having some trouble understanding your question. When you say

iam using tk to open the search results in a separate window say in word doc,PDF, openofficedoc etc.

Are you generating such a file (containing the listing of search results) on the fly and want to highlight terms in a summary associated with the result?

Are you displaying the results in some other way, but when a result is selected you want to open it in its native application with highlighting? (e.g. User searches for "foo", "foo" is found in "bar.pdf", user clicks the "bar.pdf" result in the results display, "bar.pdf" is opened in Adobe Acrobat Reader with highlighting of each instance of "foo").

Something else?

Replies are listed 'Best First'.
Re^2: how to open and highlight text
by arunmep (Beadle) on Jan 11, 2006 at 13:15 UTC
    actually i have developed a search engine which searches a set of data in different file formats(*.doc,*.pdf etc). the users gives the keyword and the search engine searches the files for the keyword instance once it is found the results are displayed along with a link to open the file in its native file format. i have done up to this part now i need to have the instance of the words in the opened file to be high lighted

      a link to open the file in its native file format

      i need to have the instance of the words in the opened file to be high lighted

      In some, and likely all, cases you are going to have to modify the file. This means that either you are going to be creating a temporary file and presenting that to the user (making highlighted search results effectively Read Only), or you are going to be making changes to the original document.

      Either way, how you go about making the changes to the files depends on the data format (i.e. you are going to need a different solution for PDF then for OpenDocument).

      Given that you are searching them already, I think it is safe to assume that you can read the files without much difficulty. This means you might want to consider the Google approach - which is to create a copy of the document in a single standard format (Google use a combination of invalid HTML and invalid CSS) and make your changes to that copy.