How to highlight a list of words in the pdf loaded on the viewer?

PDF.js Express Version

Detailed description of issue
Need to highlight words in an array sent from server. Currently highlighting is only working for the last string of array.

Expected behaviour
All words in an array must be highlighted as the doc is loaded.

Link to document
{Provide a link to the document in question if possible}

Code snippet
let arr = [‘MAX’, ‘APR’, ‘PAR38’]
for (let i = 0; i < arr.length; i++) {

      instance.docViewer.setSearchHighlightColors({
        searchResult: 'rgba(0, 255, 0, 0.5)',
        activeSearchResult: 'rgba(0, 255, 0, 0.5)'
      });
      instance.searchText(arr[i])

   
    }

    instance.closeElement('searchPanel');

Hi!

To search for multiple strings you will have to construct a regex and use that instead.

The regex /MAX|APR|PAR38/g should work.

Thanks,
Logan

Thanks Logan . I will try that.