How to replace or enhance the text search algorithm?

WebViewer Version: 8.7.0

Do you have an issue with a specific file(s)? No
Can you reproduce using one of our samples or online demos? Yes
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? No
Is your issue related to annotations? No

Please give a brief summary of your issue:
Is it possible to customize the current text search algorithm?

Please describe your issue and provide steps to reproduce it:
In its current form, the search feature supports basic text search and regular expressions. For my use case, I would like to enhance it with a custom search algorithm, specifically by adding “fuzzy search” via fuse.js.

To be clear, I’m happy with the “text extraction” performed by webviewer. I would like to take its output, perform my own search algorithm on it, and return the results back to the webviewer UI.

I have found the following avenues, but they all seem to have severe downsides:

  • UI.overrideSearchExecution – unfortunately this is limited to search executed from the UI, and ignored when calling searchText() programmatically (which is what I’d need, too)

  • Core.Document.loadPageText – this is used in the document-search sample app, but as far as I can tell it would not allow to provide the location of the search results within the document (which is what I’d need)

  • Core.PDFNet.TextSearch – this looks interesting, but I’m not sure this can be intercepted/reimplemented?

Would you have any pointers on how to integrate a custom search as seamless as possible?

Thanks!

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hi Andre,

You could refer to the sample: PDFTron Systems Inc. | Documentation to extract text on PDF pages. You’ll need to work with PDFNet.TextExtractor and implement the custom search algorithm there. After getting the search result, you can display them through Core.documentViewer.displayAdditionalResults. (PDFTron WebViewer Class: DocumentViewer)

Thanks! Yes, that seems to be a way to go, but turns out to be much harder than I thought…

Would be great if the built-in search would get a “fuzzy” option some day!