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

Implement native PDF search functionality using `pdf.js` capabilities

Open angel-langdon opened this issue 3 years ago • 8 comments

Before you start - checklist

  • [X] I understand that React-PDF does not aim to be a fully-fledged PDF viewer and is only a tool to make one
  • [X] I have checked if this feature request is not already reported

Description

pdf.js has native functionality to search inside the PDF using PDFFindController.

It would be nice for react-pdf to have an interface to access these native pdf.js useful methods

Proposed solution

I suggest adding necessary props for Document component that enables a way to search the PDF using pdf.js capabilities

Alternatives

  • Implement from zero using only pdf.js

Additional information

Related Stackoverflow posts:

  • https://stackoverflow.com/questions/35501417/how-to-search-with-pdf-js
  • https://stackoverflow.com/questions/70923975/how-to-use-pdffindcontroller-pdf-js-inside-react-pdf

angel-langdon avatar Jan 31 '22 10:01 angel-langdon

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.

github-actions[bot] avatar May 02 '22 00:05 github-actions[bot]

I managed to solve this using pdf.js API, react-virtualized and some math/programming to transform coordinates into CSS/JS valid values

You can do it without using react-virtualized but is much faster with it

angel-langdon avatar May 06 '22 12:05 angel-langdon

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.

github-actions[bot] avatar Aug 08 '22 00:08 github-actions[bot]

This issue was closed because it has been stalled for 14 days with no activity.

github-actions[bot] avatar Aug 22 '22 00:08 github-actions[bot]

@angel-langdon do you have an example of this?

nicolasiscoding avatar Mar 01 '23 03:03 nicolasiscoding

^

ryankashi avatar Sep 15 '23 06:09 ryankashi

@angel-langdon Hi, I'm facing the same issue as you, if I implement the search function with the current react-pdf, it will cause a lot of effort to draw highlight and jump, ... So could you share with us how could you deal with that problem with pdfjs and react-virtualized. Thanks in advanced!

nmaddp1995 avatar Oct 24 '23 04:10 nmaddp1995