I have integrated PDFJS
with my webpage. I want to search using javascript.
It's working fine for first time search. But then I try to search again with different keyword then it's not highlighting proper keyword.
Here is what I have tried:
// search with PDF.js
function searchPDF(td_text)
{
PDFViewerApplication.findBar.open();
PDFViewerApplication.findBar.findField.value = td_text;
PDFViewerApplication.findBar.highlightAll.checked= true;
PDFViewerApplication.findBar.findNextButton.click();
}
function resetPDFSearch()
{
if(PDFViewerApplication.findBar.findField.value != '') {
PDFViewerApplication.findBar.findField.value = '';
PDFViewerApplication.findBar.highlightAll.checked= false;
PDFViewerApplication.findController.reset();
PDFViewerApplication.findBar.close();
PDFViewerApplication.findController.matchCount = 0;
PDFViewerApplication.findController.updateMatch();
}
}
In above function, when I call searchPDF()
first time then keyword is highlighting properly. But again if I call same function with different keyword then it shows previously highlighted keyword only.
I try to create new function resetPDFSearch()
to reset all previously filtered and highlighted keywords. But no luck.
Thanks in advance.