# loadPageText of docviewer instance is not found

**URL:** <https://pdfjs.community/t/loadpagetext-of-docviewer-instance-is-not-found/535>\
**Category:** Technical Support\
**Created:** [February 23, 2021, 9:58am UTC](https://pdfjs.community/t/loadpagetext-of-docviewer-instance-is-not-found/535 "2021-02-23T09:58:27Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![shubhangida](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@shubhangida](https://pdfjs.community/u/shubhangida)\
**Post date:** [February 23, 2021, 9:58am UTC](https://pdfjs.community/t/loadpagetext-of-docviewer-instance-is-not-found/535/1 "2021-02-23T09:58:28Z")

</div>

- 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.

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [March 1, 2021, 5:25pm UTC](https://pdfjs.community/t/loadpagetext-of-docviewer-instance-is-not-found/535/2 "2021-03-01T17:25:35Z")

</div>

Hey there!

If you are just looking to search and highlight words, I recommend using our built in search APIs rather than doing the search yourself. Below are a few guides to get you started:

- [Basic search and highlight](https://pdfjs.express/documentation/search/basic-search)
- [Advanced search](https://pdfjs.express/documentation/search/advanced-search)

If these don’t work for you, let me know.

Thanks!  
Logan

---

<div class="post-metadata">

**Author:** ![shubhangida](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@shubhangida](https://pdfjs.community/u/shubhangida)\
**Post date:** [March 9, 2021, 12:17pm UTC](https://pdfjs.community/t/loadpagetext-of-docviewer-instance-is-not-found/535/3 "2021-03-09T12:17:59Z")

</div>

Thank You for the response!!

I have tried both the solutions, in the advance search I’m getting following error :

 ![pdf-express](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/077064ba4bc5fe608f8971dc1bdf9f381f5fe353.jpeg)

I have implemented the same example which was there in the documention.

Can you please check and let me know ?

Thank You.

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [March 9, 2021, 4:34pm UTC](https://pdfjs.community/t/loadpagetext-of-docviewer-instance-is-not-found/535/4 "2021-03-09T16:34:19Z")

</div>

Hey there,

It looks like there’s an error in your setup. That first error message is probably breaking stuff.

Can you send the code you’re using to initialize Express? My guess is that theres an error loading the resources.

Thanks!  
Logan

---

<div class="post-metadata">

**Author:** ![shubhangida](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@shubhangida](https://pdfjs.community/u/shubhangida)\
**Post date:** [March 10, 2021, 6:22am UTC](https://pdfjs.community/t/loadpagetext-of-docviewer-instance-is-not-found/535/5 "2021-03-10T06:22:14Z")

</div>

Here is the code,

```
import React, { useEffect } from 'react';
import WebViewer from '@pdftron/pdfjs-express';

function AdvanceSearch(props) {

    useEffect(() => {
        WebViewer(
            {
                path: '/webviewer/lib',
                initialDoc: '/files/pdftron_about.pdf',
            },
            document.getElementById('viewer')
          ).then(instance => {
            const {Annotations, docViewer, CoreControls, annotManager, } = instance;
            docViewer.on('documentLoaded', () => {
              const searchMode = CoreControls.Search.Mode.PAGE_STOP;
              const searchOptions = {
                fullSearch: true,
                onResult: (result) => {
                  const textQuad = result.quads[0].getPoints();
                  const annot = new Annotations.TextHighlightAnnotation();
          
                  annot.X = textQuad.x1;
                  annot.Width = textQuad.x2 - textQuad.x1;
                  annot.Y = textQuad.y3;
                  annot.Height = textQuad.y1 - textQuad.y3;
                  annot.FillColor = new Annotations.Color(0, 0, 255, 0.5);
                  annot.StrokeColor = new Annotations.Color(0, 0, 255, 0.5);
                  annot.Quads = [textQuad];
                
                  annotManager.addAnnotation(annot);
                  annotManager.drawAnnotationsFromList([annot]) 
                }
              }
              docViewer.textSearchInit('PDF', searchMode, searchOptions);
            })
          })
    })
    
    return (
        <div className="App">
            <div className="header">React sample</div>
            <div className="webviewer" id="viewer"></div>
        </div>
    );
}

export default AdvanceSearch;

```

Please check, Thank you.

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [March 12, 2021, 7:35pm UTC](https://pdfjs.community/t/loadpagetext-of-docviewer-instance-is-not-found/535/6 "2021-03-12T19:35:01Z")

</div>

Hey there,

It looks like you are not using `useEffect` correctly. You are not passing in the second parameter, which means that WebViewer will be mounted multiple times and that will probably cause issues.

Try passing an empty dependancy array to useEffect and see if that fixes it…

```javascript
useEffect(() => {
   ... your express code
}, [])

```

Thanks!  
Logan

---

<div class="post-metadata">

**Author:** ![shubhangida](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@shubhangida](https://pdfjs.community/u/shubhangida)\
**Post date:** [March 17, 2021, 8:17am UTC](https://pdfjs.community/t/loadpagetext-of-docviewer-instance-is-not-found/535/7 "2021-03-17T08:17:46Z")

</div>

Hi Logan,

This is not working as well.  
sharing the updated code with you and screenshot of error(getting same as before).

```
useEffect(() => {
    WebViewer(
        {
            path: '/webviewer/lib',
            initialDoc: '/files/pdftron_about.pdf',
        },
        document.getElementById('viewer')
      ).then(instance => {
        const {Annotations, docViewer, CoreControls, annotManager, } = instance;
        docViewer.on('documentLoaded', () => {
          console.log("asss", CoreControls);
          const searchMode = CoreControls.Search.Mode.PAGE_STOP;
          const searchOptions = {
            fullSearch: true,
            onResult: (result) => {
              const textQuad = result.quads[0].getPoints();
              const annot = new Annotations.TextHighlightAnnotation();
      
              annot.X = textQuad.x1;
              annot.Width = textQuad.x2 - textQuad.x1;
              annot.Y = textQuad.y3;
              annot.Height = textQuad.y1 - textQuad.y3;
              annot.FillColor = new Annotations.Color(0, 0, 255, 0.5);
              annot.StrokeColor = new Annotations.Color(0, 0, 255, 0.5);
              annot.Quads = [textQuad];
            
              annotManager.addAnnotation(annot);
              annotManager.drawAnnotationsFromList([annot]) 
            }
          }
          docViewer.textSearchInit('PDF', searchMode, searchOptions);
        })
      })
}, [])

```

Screenshot of error:

 ![pdfexpress](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/652cf8b9419da9422c4ffe561c0530f31ff9e535.jpeg)

Please check, Thank you.

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [March 17, 2021, 3:08pm UTC](https://pdfjs.community/t/loadpagetext-of-docviewer-instance-is-not-found/535/8 "2021-03-17T15:08:37Z")

</div>

Hey there,

Looks like you’re using an older version of Express (I realize that our samples haven’t been updated to use 7.x.x).

Please make sure you’re using the latest version, and then let me know if you still have this issue.

Thanks!

---

<div class="post-metadata">

**Author:** ![shubhangida](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@shubhangida](https://pdfjs.community/u/shubhangida)\
**Post date:** [March 19, 2021, 8:34am UTC](https://pdfjs.community/t/loadpagetext-of-docviewer-instance-is-not-found/535/9 "2021-03-19T08:34:46Z")

</div>

I have updated the version to latest one as you said.  
it is now - “@pdftron/pdfjs-express”: “^7.3.1”  
still getting the same error as I already shared with you.  
Please, look into this and let me know.

Thank you.

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [March 22, 2021, 9:30pm UTC](https://pdfjs.community/t/loadpagetext-of-docviewer-instance-is-not-found/535/10 "2021-03-22T21:30:01Z")

</div>

Hi,

I cannot reproduce your issue.

Please make sure that Express is getting loaded properly and that `/webviewer/lib` contains all the files necessary.

I would recommend deleting the entire contents of `/webviewer/lib` and reinstalling PDF.js Express from a clean state.

Thanks!
