Using TextSearch in PDFNet SDK


I’m trying to search for a particular text in a pdf file using the following method :

pdftron.PDF.TextSearch.ResultCode Run(ref int page_num, ref string result_str, ref string ambient_str, Highlights hlts);

Here, the method returns the ‘page_num’ of the file where it gets the ‘text to be searched’ first and do not search for it further. However, I need to search for the next occurrence of the text as well in the file. My search text in present on each page of the pdf file. And I need to get all the occurences on each page.


It seems that all that you are looking for is covered in TextSearch sample:

With TextSearch you can go through all instances of a given word on a specific Page (or all pages in the document). You can also obtain the positioning info for each match (using TextSearch.SearchMode.e_highlight search mode and Highlights.GetCurrentQuads). This is also illustrated in TextSearch sample.