# Search feature not finding results after page load

**URL:** <https://pdfjs.community/t/search-feature-not-finding-results-after-page-load/742>\
**Category:** Technical Support\
**Created:** [April 30, 2021, 8:41pm UTC](https://pdfjs.community/t/search-feature-not-finding-results-after-page-load/742 "2021-04-30T20:41:48Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![andy](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@andy](https://pdfjs.community/u/andy)\
**Post date:** [April 30, 2021, 8:41pm UTC](https://pdfjs.community/t/search-feature-not-finding-results-after-page-load/742/1 "2021-04-30T20:41:48Z")

</div>

**PDF.js Express Version**  
7.3.1

**Detailed description of issue**  
When I load a document like the one included, and I search for the term `at-home administration` it doesn’t appear to find the results.

However if I open the pages panel and scroll all the way to the last page, then hit search again it finds them.

**Expected behaviour**  
The search feature should find the results like so:

 ![Screen Shot 2021-04-30 at 1.39.39 PM](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/bf1e567968bc7db4b006f98dbeeac1ecba0ebb8a.png)

**Does your issue happen with every document, or just one?**  
I only tested this one.

**Link to document**

> **[REV\_206966\_206966ORIG1S000MEDR.PDF](https://storage.googleapis.com/dev-myindago-sba-pdfexpress/REV_206966_206966ORIG1S000MEDR.PDF)**
>
> 4.22 MB

**Code snippet**  
N/A

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/ffbcd25c7d423db8d5acd5db201c272f4db306dd.png) [@system](https://pdfjs.community/u/system)\
**Post date:** [April 30, 2021, 8:41pm UTC](https://pdfjs.community/t/search-feature-not-finding-results-after-page-load/742/2 "2021-04-30T20:41:51Z")

</div>

**Hello, I’m Ron, an automated tech support bot 🤖**

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

Guides:
- [PDF.js Express Viewer](https://pdfjs.express/documentation/viewer/overview)
- [Create annotations - Programmatically](https://pdfjs.express/documentation/annotation/create-annotations#programmatically)
- [Core engine for WebViewer - Creating your own UI using WebViewer Core](https://pdfjs.express/documentation/ui-customization/core#creating-your-own-ui-using-webviewer-core)

APIs:
- [CoreControls.DisplayModeManager - setDisplayMode(displayMode)](https://pdfjs.express/api/CoreControls.DisplayModeManager.html#setDisplayMode__anchor)
- [CoreControls](https://pdfjs.express/api/CoreControls.html#__anchor)
- [CoreControls.Document - loadAsync(partRetriever, callback, options)](https://pdfjs.express/api/CoreControls.Document.html#loadAsync__anchor)

Forums:
- [Issue searching documents with different size pages](https://pdfjs.community/t/issue-searching-documents-with-different-size-pages/578/1)
- [Form fields not visible](https://pdfjs.community/t/form-fields-not-visible/118/1)
- [Executing TextSearchInit multiple times](https://pdfjs.community/t/executing-textsearchinit-multiple-times/712/1)

---

<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:** [May 4, 2021, 2:15pm UTC](https://pdfjs.community/t/search-feature-not-finding-results-after-page-load/742/3 "2021-05-04T14:15:58Z")

</div>

Hi there!

Can you please share the code you’re using to search the document? And also the code you are using to load PDF.js Express. My suspicion is that there is a timing error and the document isn’t fully loaded before you search.

Thanks you,  
Logan

---

<div class="post-metadata">

**Author:** ![andy](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@andy](https://pdfjs.community/u/andy)\
**Post date:** [May 6, 2021, 12:14am UTC](https://pdfjs.community/t/search-feature-not-finding-results-after-page-load/742/4 "2021-05-06T00:14:05Z")

</div>

Hey Logan, so I am just using the search field in the sidebar to do the search not running any commands to manually do it. Does the document work for you when you test it?

Here’s the code I am running to load it:  
WebViewer({  
path: ‘…/…/Content/pdfexpress’, // path to the PDF.js Express’lib’ folder on your server  
licenseKey: ‘Insert commercial license key here after purchase’,  
initialDoc: ‘/Content/FlowPaper/services/awsview.ashx?doc=’ + filePath + ‘&format=pdf&page={page}&aws=’ + awsName,  
disableFlattenedAnnotations: true,  
annotationUser: authorName,  
disabledElements: [  
‘toolbarGroup-Shapes’,  
‘toolbarGroup-Insert’,  
‘unpostedCommentIndicator’,  
‘noteState’,  
‘eraserToolButton’,  
‘toolsOverlay’  
]  
})

---

<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:** [May 10, 2021, 8:34pm UTC](https://pdfjs.community/t/search-feature-not-finding-results-after-page-load/742/5 "2021-05-10T20:34:49Z")

</div>

Hey Andy,

I can reproduce your issue with that document. It is a pretty big document so my suspicion is that we’re not loading all of the pages while searching. I’ll look into it.

Thanks!  
Logan

---

<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:** [May 11, 2021, 3:14pm UTC](https://pdfjs.community/t/search-feature-not-finding-results-after-page-load/742/6 "2021-05-11T15:14:29Z")

</div>

Hi Andy!

This was a tricky one but we found a fix. As a side effect, we were also able to make search about 50% faster on long documents! This fix will be pushed with the next release.

Thanks for reporting this bug,  
Logan

---

<div class="post-metadata">

**Author:** ![andy](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@andy](https://pdfjs.community/u/andy)\
**Post date:** [May 11, 2021, 6:48pm UTC](https://pdfjs.community/t/search-feature-not-finding-results-after-page-load/742/7 "2021-05-11T18:48:03Z")

</div>

Yes!!! Thanks for jumping on this, and glad it wasn’t only a bug I saw.  
Looking forward to the fix.

---

<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:** [June 4, 2021, 4:59pm UTC](https://pdfjs.community/t/search-feature-not-finding-results-after-page-load/742/8 "2021-06-04T16:59:26Z")

</div>

Hi @andy

We just released 7.3.3 which fixes this issue. Sorry for the wait!

Thanks,  
Logan

---

<div class="post-metadata">

**Author:** ![andy](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@andy](https://pdfjs.community/u/andy)\
**Post date:** [June 4, 2021, 6:03pm UTC](https://pdfjs.community/t/search-feature-not-finding-results-after-page-load/742/9 "2021-06-04T18:03:06Z")

</div>

Thanks Logan! I’ll get started on testing it soon, thanks again for jumping on that!

---

<div class="post-metadata">

**Author:** ![andy](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@andy](https://pdfjs.community/u/andy)\
**Post date:** [September 23, 2021, 6:15pm UTC](https://pdfjs.community/t/search-feature-not-finding-results-after-page-load/742/10 "2021-09-23T18:15:23Z")

</div>

Hey @Logan everything is looking good and working better. However I still have a search issue related to not finding certain terms in a document.

**PDF.js Express Version**  
8.0.1

**Detailed description of issue**  
When I try searching the term `home administration` I am unable to find it even though it exists in many places in the document.

**Expected behaviour**  
It should find all search terms.  
 ![Screen Shot 2021-09-23 at 10.52.16 AM](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/aee0d4e71797c38cf5cd3693e5376daa7ed06534.png)  
 ![Screen Shot 2021-09-23 at 10.52.36 AM](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/dbdbfbfecde9104b00ffebfbf5cbed7af06f353a.png)

**Does your issue happen with every document, or just one?**  
I tested in multiple documents.

**Link to document**

> **[636998628510527818\_REV\_125472\_125472ORIG1S000ADMINCORRES.PDF](https://storage.googleapis.com/dev-myindago-sba-pdfexpress/636998628510527818_REV_125472_125472ORIG1S000ADMINCORRES.PDF)**
>
> 19.62 MB
