Is there a way to use multiple keywords in one search

Recently I am using webviewer text search functions to perform word search on pdf. I am wondering is there a way to do a multiple keywords search and highlight each different keyword different color?
For example, if I use “PDF” as first keyword to search and highlight the this keyword occurrences on pdf, then I put " search " as second keyword, the pdf will highlight “PDF” and “search” with different color.
Is it possible to do this ?
thank you

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Thank you for contacting us about WebViewer. You can override the search function and change it to use regex search. You can do something like the following

Webviewer({}, document.getElementById('viewer')).then(async instance => {
  const { annotManager, docViewer, Annotations } = instance;	

  const orginalSearch = instance.UI.searchTextFull;
  instance.UI.overrideSearchExecution((searchTerm, options) => {
    // change search term to regex, so in the form of "searchTerm1|searchTerm2|etc"
    options.regex = true;
    orginalSearch.apply(this, [searchTerm, options]);
  });
});

Please let me know if the above was helpful or if you want me to clarify something.

Best Regards,

Andrew Yip
Software Developer
PDFTron Systems, Inc.
www.pdftron.com

thank you I am going to try it now

actually besides the Webviewer UI, I also need to perform programmatic search on multiple keywords. How can I use something similar to "instance.UI.overrideSearchExecution " on programmatic search?
thank you

Hi,

The instance.UI.overrideSearchExecution API is used to override the search used in the UI built in search panel. Depending on what you are doing you might not need to use it. You can see our guide on text search for more information
Search guide

You’ll mainly need to set the regex flag to true and pass in a regex string

Best Regards,

Andrew Yip
Software Developer
PDFTron Systems, Inc.
www.pdftron.com