Foxit PDF SDK for Web

Foxit PDF SDK for Web: Search

With PDF SDK, text search enables you to search a string across thousands of documents since the full content (including split text, combined words, metadata, annotations and so on) is indexed. This means no more sifting through endless reams of paper to find that all important contract or invoice again. Text search takes seconds to execute and your query can be as simple or complex as needs be.

Our search functionality in the Web SDK is more UI based. To use more text search functionality than shown in the sample below, you must use annotations as per the developer guide.

How to programmatically perform text search in PDF SDK for Web

function searchText() {
//Search functionality code comes here  
//Search for 'foxit' 
//If find respective instance, add alert button - alert and provide quick info about where the match is 
var doc = pdfViewer.getCurrentPDFDoc(); 
doc.getPageByIndex(0).then(function(firstPage) { 
firstPage.getTextSearch('Foxit', PDF.constant.Search_Flag.wholeWord).then(function(textSearch){ 
textSearch.findNext().then(function(matchInfo) { 
if(!matchInfo) { 
alert('Nothing match'); 
} else { 
alert( 
JSON.stringify(matchInfo) 
); 
} 
}) 
); 
}); 
};

Updated on June 29, 2021

Was this article helpful?
Thanks for your feedback. If you have a comment on how to improve the article, you can write it here: