WebViewer Version: 7.3.3
Do you have an issue with a specific file(s)?
No
Can you reproduce using one of our samples or online demos?
Yes for a single search term works fine. But if I iterate over an array of search terms only the results for the last element is returned.
Used eg from https://www.pdftron.com/documentation/web/guides/advance-text-search/
Is it possible to run textSearchInit multiple times and get all the results?
Are you using the WebViewer server?
No
Does the issue only happen on certain browsers?
No
Is your issue related to a front-end framework?
React
Is your issue related to annotations?
No
Please give a brief summary of your issue:
Unable to run docViewer.textSearchinit over an array of search terms
Please provide a link to a minimal sample where the issue is reproducible:
Using the following git hub sample project as a start point
I replaced the useEffect with the following useEffect. The console output only had results for “scratch”
useEffect(() => {
WebViewer(
{
path: "/webviewer/lib",
initialDoc: "/files/PDFTRON_about.pdf",
},
viewer.current
).then((instance) => {
const { docViewer, CoreControls } = instance;
docViewer.on("documentLoaded", () => {
const searchTextList = ["mistake", "scratch"];
const mode =
CoreControls.Search.Mode.PAGE_STOP |
CoreControls.Search.Mode.HIGHLIGHT |
CoreControls.Search.Mode.WHOLE_WORD;
searchTextList.forEach((s) => {
const searchOptions = {
fullSearch: true,
onResult: (result) => {
if (result.resultCode === CoreControls.Search.ResultCode.FOUND) {
console.log(result);
}
},
};
docViewer.textSearchInit(s, mode, searchOptions);
});
});
});
}, []);