We have a problem with document that we attached to this issue. When we try to highlight whole word "is" code is preacking on line :
List<PdfTextFragment> result = finder.Find(word);
with error :Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'startIndex')[/b]
It is always happening on the same page 181. This page has 13 occurrences of word "is" and das not seam to have any problematic characters, and by that time we find more then 2000 occurrences of the word. On document containing only this page it is working without error. We tested document with other words like "and" and it was working well and occurrences of word that we find was more then 3000.
This is the part of the code that we use dictionary has only one word "is" for testing:
dictionary = dictionary.OrderByDescending(x => x.Length).ToList();
PdfUsedFont[] usedfont = doc.UsedFonts;
PdfBrush brush = new PdfSolidBrush(Color.Black);
replaceNum = 0;
PdfTextFindOptions findOptions = new PdfTextFindOptions();
findOptions.Parameter = TextFindParameter.WholeWord | TextFindParameter.IgnoreCase;
foreach (PdfPageBase page in doc.Pages)
{
foreach (string word in dictionary)
{
PdfTextFinder finder = new PdfTextFinder(page);
finder.Options = findOptions;
List<PdfTextFragment> result = finder.Find(word);
replaceNum = replaceNum + result.Count();
if (result.Count > 0)
{
foreach (PdfTextFragment findWord in result)
{
findWord.HighLight(colour);
}
}
}
}
If you need any other data please let me know.
Regards
Biljana.