react-pdf-highlighter icon indicating copy to clipboard operation
react-pdf-highlighter copied to clipboard

dynamic highlighting from passages

Open salimbene opened this issue 6 years ago • 3 comments
trafficstars

Hello there...

Is is possible to dynamically hightlight from text? I have an app that searches information on pdf's and present the users a list of results. Each results is a paragraph. I would like to present the option of opening the PDF and show the found passage highlighted. I've been looking at the code, but the coordinates from the examples is hardcoded. I see that you can manually highlight text, but i didn't find a way to programatically calculate the coordinates search by searching text.

Thanks! And kudos, great library!

salimbene avatar May 03 '19 20:05 salimbene

Do you also have PDF coordinates with your search results? If so, you can set usePdfCoordinates to true when passing an array of highlights: https://github.com/agentcooper/react-pdf-highlighter/blob/b576d7f95172bba45a1d043400c6b83c04570dfb/src/types.js#L31.

agentcooper avatar May 04 '19 14:05 agentcooper

Hey agentcooper. No, I don't have coordinates with my search results. In case you are familiar with, I'm using IBM Watson Discovery to search in PDF that are ingested in discovery. The API provides search results and the document name, but it doesnt provide coordinates. I would need to search a passage within the pdf manually to have it highlighted.

salimbene avatar May 04 '19 22:05 salimbene

How can I find programmatically the text in the PDF? I would like to search the text using an api such as this one provided by ngx-extended-pdf-viewer, , see the example in https://pdfviewer.net/find So, once I passed the search text and it is highlighted in the document, the user could add the annotation.

wisespace-io avatar Feb 29 '20 13:02 wisespace-io