loadPageText of docviewer instance is not found

  • We are not able to find below two methods (loadPageText & getTextPosition) in the docviewer object, same things are
    working in the pdftron.

  • Kindly suggest what we need to do the changes so, we can highlight all the search words in the pdf.

  • We are using “@pdftron/pdfjs-express”: “^7.2.2” as node-modules.

     docViewer.on('documentLoaded', async () => {
              const doc = docViewer.getDocument();
              console.log(doc);
              var serachArr = ['PDF', 'SDK', 'interest'];
              var searchTerm = '';
              var finalQuads = [];
              const pageNumber = 2;
              async function test() {
                  for (let i = 0; i < serachArr.length; i++) {
                      console.log('Before await for ', serachArr[i]);
                      let result = await Promise.resolve(serachArr[i]);
                      console.log('After await. Value is ', result);
                      searchTerm = serachArr[i];
                      const pageText = await doc.loadPageText(pageNumber);
                 
                      let startIndex = 0;
                      let endIndex = 0;
                      if (pageText != undefined) {
                          while (startIndex > -1) {
                              startIndex = pageText.indexOf(searchTerm, endIndex);
                              endIndex = startIndex + searchTerm.length;
                              const quads = await doc.getTextPosition(pageNumber, startIndex, endIndex);
                              quads.map((data) => {
                                  if (data.x1 != undefined) {
                                      finalQuads.push(data);
                                  }
                              })
                          }
                      }
                      highlight.PageNumber = pageNumber;
                      highlight.StrokeColor = new Annotations.Color(255, 255, 0);
                      console.log("searchTerm", searchTerm);
                      console.log("final === ", finalQuads);
                  }
              }
    
              test().then(_ => {
                  highlight.Quads = finalQuads;
                  console.log(finalQuads[0]);
                  annotManager.addAnnotation(highlight);
                  annotManager.drawAnnotations(highlight.PageNumber);
                  console.log('After test() resolved')
              });
              console.log('After calling test');
          })