Is it possible to use textSearchInit to search for a list of terms?

WebViewer Version: 7.3.3

Do you have an issue with a specific file(s)?

Can you reproduce using one of our samples or online demos?
Yes for a single search term works fine. But if I iterate over an array of search terms only the results for the last element is returned.
Used eg from

Is it possible to run textSearchInit multiple times and get all the results?

Are you using the WebViewer server?

Does the issue only happen on certain browsers?

Is your issue related to a front-end framework?

Is your issue related to annotations?

Please give a brief summary of your issue:
Unable to run docViewer.textSearchinit over an array of search terms

Please provide a link to a minimal sample where the issue is reproducible:
Using the following git hub sample project as a start point

I replaced the useEffect with the following useEffect. The console output only had results for “scratch”

useEffect(() => {



    path: "/webviewer/lib",

    initialDoc: "/files/PDFTRON_about.pdf",



).then((instance) => {

  const { docViewer, CoreControls } = instance;

  docViewer.on("documentLoaded", () => {

    const searchTextList = ["mistake", "scratch"];

    const mode =

      CoreControls.Search.Mode.PAGE_STOP |

      CoreControls.Search.Mode.HIGHLIGHT |


    searchTextList.forEach((s) => {

      const searchOptions = {

        fullSearch: true,

        onResult: (result) => {

          if (result.resultCode === CoreControls.Search.ResultCode.FOUND) {





      docViewer.textSearchInit(s, mode, searchOptions);




}, []);

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:



Thank you for the sample code. Currently calling “textSearchInit” again will cancel the current search and start searching with the new search term. You can use the “CoreControls.Search.Mode.REGEX” and do a regex search (can search for “mistake|scratch”). Please let me know if that works for you or if you have any other questions

Best Regards,

Andrew Yip
Software Developer
PDFTron Systems, Inc.

1 Like

Hi Andrew,

That work brilliantly! Thank you.
For the time being this seems to do the job, not entirely sure how performant it would be for larger set of search terms. Will probably need to look at a server side solution for that if the need arises.

Thanks again.