Which product are you using?
PDF.js Express Viewer
PDF.js Express Version
8.7.2
Detailed description of issue
There are two very related issues
- If I search something twice using the UI.searchText API, I get an error message on the console saying
searchText.js:107 TypeError: Cannot read properties of undefined (reading 'text')
at e.zC (webviewer-core.min.js:1559:222)
at e.wg (webviewer-core.min.js:1544:33)
at r (webviewer-core.min.js:324:55)
- If the second search is for a different string that is not located in the pdf (i.e. no results found), the previous search result highlight is not cleared. How to clear older results each time a new search is initiated?
Expected behaviour
- There should be no error on the console for a repeated search.
- On initiation of a new search, the previous search result should be cleared.
Does your issue happen with every document, or just one?
Yes
Code snippet
var search = function(search_term) {
// search_term = 'Annotate'
console.log("Initiating search: " + search_term)
pdfjs_instance.UI.searchText(search_term, {
wildcard:false
})
pdfjs_instance.UI.closeElements([ 'searchPanel' ]);
}
var searchListener = function(searchValue, options, results) {
console.log(`CALLBACK: ${searchValue}.`)
// console.log(options);
console.log(results);
console.log(`Time taken ${(performance.now() - start_time) / 1000}s. Total results found ${results.length}`)
};
// for 1
search('Annotate')
search('Annotate')
//for 2
search('Annotate')
search('asdasd')