We have implemented a search function that iterates over pages,
extracts text runs (ElementReader), and annotates matches. The
application is also using PDFView class to render the PDF.
If a search match is found and another search is initiated in rapid
succession, the PDFNet api throws exceptions (non-deterministically).
The problem seems to related to threading issue, however our code that
uses PDFView is only single threaded.
The problem is that even though your code is using only a single
thread, PDFView class is using another thread for interactive
rendering. This means that whenever you are accessing the document you
need to lock it. For example:
... read/write/edit the document...
P.S. The upcoming version of PDFNet will have built-in support for
text search however users will still be able to disable this feature
and implement their custom methods.