# Cancel/abort search programmatically

**URL:** <https://pdfjs.community/t/cancel-abort-search-programmatically/3516>\
**Category:** Technical Support\
**Created:** [November 12, 2024, 10:23am UTC](https://pdfjs.community/t/cancel-abort-search-programmatically/3516 "2024-11-12T10:23:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![prajneshu.khandavall](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@prajneshu.khandavall](https://pdfjs.community/u/prajneshu.khandavall)\
**Post date:** [November 12, 2024, 10:23am UTC](https://pdfjs.community/t/cancel-abort-search-programmatically/3516/1 "2024-11-12T10:23:33Z")

</div>

**Which product are you using?**  
PDF.js Express Plus

**PDF.js Express Version**  
8.7.2

**Detailed description of issue**  
we are using “textSearchInit” api for multi word searching. we are looking for cancel/abort search option/api to stop search further. is there any way to do?

**Expected behaviour**  
search should stop immediatly

**Does your issue happen with every document, or just one?**  
yes

**Link to document**  
NA

**Code snippet**  
NA

---

<div class="post-metadata">

**Author:** ![tgordon](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@tgordon](https://pdfjs.community/u/tgordon)\
**Post date:** [November 12, 2024, 11:47pm UTC](https://pdfjs.community/t/cancel-abort-search-programmatically/3516/3 "2024-11-12T23:47:35Z")

</div>

Hello prajneshu.khandavall,

In the [textSearchInit](https://pdfjs.express/api/Core.DocumentViewer.html#textSearchInit) you can set the options for what type of search.  
You can set fullSearch to false to do a single search, or true for a full search.  
The onResult callback is called when a result is found. You could then call: documentViewer.clearSearchResults() to stop the search and clear the search UI

Best regards,  
Tyler
