in reply to Re: how to open and highlight text
in thread how to open and highlight text

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

Replies are listed 'Best First'.
Re^3: how to open and highlight text
by dorward (Curate) on Jan 11, 2006 at 13:27 UTC

    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.