1
Is it possible to highlight mulitple phrases rather than individual words?
Question asked by Neil McDonald - 8/25/2025 at 4:44 PM
Answered
Hi,

I am passing a number of words and phrases to a DocumentUltimate page and storing them in a list object. I would like to highlight all of the words and phrases contained within the list, but I only seem to be able to highlight individual words. Is it possible to do this? 

e.g. If my object contains ["red", "four wheels", "petrol"], I would like to highlight as below:

The red car has four doors, four wheels and a petrol engine.

I've tried various client-side suggestions from AI without success.

Many Thanks,
Neil.
0
Cem Alacayir Replied
Employee Post
You should use MatchOptions.MatchAnyWord

documentViewer.SearchOptions.Term = "red four wheels petrol";
documentViewer.SearchOptions.MatchOptions = MatchOptions.MatchAnyWord;
0
Neil McDonald Replied
That matches all instances of "four" and "wheels" though. Is it not possible to specify phrases and individual words to match?
0
Cem Alacayir Replied
Employee Post Marked As Answer
Ok, this is now possible:

Version 7.7.0 - August 26, 2025

  • Improved: When using DocumentViewerMatchOptions.MatchAnyWord, now the quotation marks can be used to specify phrases
    inside a query that is set via DocumentViewerSearchOptions.Term.
    For example;

    • red "four wheels" petrol will match red or four wheels or petrol or red four wheels petrol

    • red ""four wheels"" petrol will match red or "four wheels" or petrol or red "four wheels" petrol

    • C#
      documentViewer.SearchOptions.Term = "red \"four wheels\" petrol";
      documentViewer.SearchOptions.MatchOptions = MatchOptions.MatchAnyWord;
      
      //If you have an array of phrases, you can surround them with quotation marks 
      //and then join them with spaces to form a query:
      var phrases = new[] { "red", "four wheels", "petrol" };
      var query = string.Join(" ", phrases.Select(p => $"\"{p}\""));
      documentViewer.SearchOptions.Term = query;
      documentViewer.SearchOptions.MatchOptions = MatchOptions.MatchAnyWord;

    Note that two consecutive quotation marks "" can be used to escape, i.e. to search for a quotation mark literally as ".
    The same feature can also be used in the Viewer's Find dialog.

1
Neil McDonald Replied
Wow, that was fast. Thank you so much!

Reply to Thread

Enter the verification text