THREAD-BASED TEXT SEARCH IN PDF DOCUMENTS
New features have been added to the interface of the PDF Reader Library. The previous Text Search solution could search the text on the PDF document, but you could not stop the search during the process. This is not a problem in a non-interactive application, but it could be a problem if a user searches for text that doesn’t exist in a 1000-page document. Now, there is another tool for searching, the thread-based text search.
How to use this tool
You can start a thread for text searching by calling the StartTextSearchThread member function of a CPDF object. During text searching the thread sends messages at the following events:
End of the page
End of the text search
Finished the text search
In the client application you can get these messages with parameters (TextSearchInfo structure) and handle the events. The TextSearchInfo structure contains the following information:
(ET_ENDPAGE, ET_FOUNDTEXT, ET_ENDDOCUMENT, ET_FINISHED, ET_DEFAULT) that define the type of the event
that contains the current page during the text search
that contains the position of the found text
that is a pointer to the CPDF object that started the text search thread
The PDF Reader Demo Sample Application already uses this feature.
If any text is found the thread stops. If you want to continue searching, you can call one of the following functions:
continue the searching of the original text in the original direction
continue forward the searching of the original text
continue backward the searching of the original text
One can stop the search by calling the StopTextSearchThread member function. It is used for example when the user wants to interrupt the process (the sample uses it when user clicks on the STOP button on the Text Searching dialog).
With this tool it is easy to develop an interactive text search in PDF documents.
For more information please read the PDF SDK online manual in the following place: