How to enhance PDFViewCtrl.FindText

We implemented a viewer that utilizes key data for fast key searches
of PDF documents. Works great! A fall back we provide (like your
viewer sample) is to provide a regular full document searche. Our
documents are typically 50,000 to 250,000 pages, so obviously very
slow going. We avoid the built in search text dialog because we ALSO
offer the keyed search in our enhanced UI. We use FindText for full-
document search mode. A few awkward issues though...

o FindText offers no working/progress for us to give feedback to the
user that its working.
o FindText offers no CANCEL
o We tried putting it in a background worker, so we could provide a UI
state for working, and then clear it when the worker returns, but
FindText returns immediately anyway.
o FindText highlights the found text, but we can't figure out how to
use this for print/selection (we had to override the print function as
well - trying to avoid defaulting to print-full-document)
o FindText quickly jumps to the next page, and then waits a long time
until it finds something before we hear back. Visually this is
confusing to the user.

Any help you can provide for chinking our way in to improve some of
these would be greatly appreciated. I'm always amazed at what is

For this purpose, you are better off with the TextSearch class. You can use
it to search the content and query the search results for highlighting.
There is a detailed TextSearch sample code at

However, a few things to notice:

1. You can call TextSearch::Run() in your worker thread. But you will need
to call PDFDoc::Lock() before and PDFDoc::Unlock() after it. This is because
your viewer may be accessing the same document and simultaneous access to
the same PDFDoc instance from different threads is not allowed.
2. After the key string is found, you can use SearchResult::GetHighlights()
to retrieve all the necessary information for highlighting. Simply, you can
just use PDFView::Select(Highlights) & highlights), or you can draw into the
buffer yourself if you prefer a different look.