mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
47.96k stars 9.92k forks source link

[Bug]: "Find" doesn't match text in popup annotations #18591

Open garydeng01 opened 1 month ago

garydeng01 commented 1 month ago

Attach (recommended) or Link to PDF file

popup_example.pdf

Web browser and its version

Chrome 124.0.6367.92

Operating system and its version

Windows 10 Enterprise 22H2

PDF.js version

v4.5.136

Is the bug present in the latest PDF.js version?

Yes

Is a browser extension

No

Steps to reproduce the problem

  1. Get the PDF.JS code
  2. Replace "web/compressed.tracemonkey-pldi-09.pdf" with "popup_example.pdf"
  3. Build the project and launch the local server
  4. Navigate to the local URL
  5. Click the yellow popup annotation in order to expand it
  6. Click within the pdf viewer to make sure it's active
  7. Press Ctrl-F to bring up the search text box
  8. Type in "seashells"
  9. Observe that the find module reports "phrase not found"
  10. Click within the address bar of the browser
  11. Press Ctrl-F to bring up the browser's search text box
  12. Type in "seashells"
  13. Observe that one of the search match results is the text within the expanded popup annotation

What is the expected behavior?

PDF.JS's search module finds the matching "seashells" phrase in the expanded popup annotation.

What went wrong?

PDF.JS's search module does not find the matching "seashells" phrase in the expanded popup annotation. image

Link to a viewer

No response

Additional context

No response

nicolo-ribaudo commented 1 month ago

Do you expect it to search also in annotations that are not open (those that only open when you pass the mouse on them), or in all of them?

This seems interesting and if the maintainers like the feature I will probably submit a PR at some point, but maybe it should be opt-in through a checkbox in the search bar,

Snuffleupagus commented 1 month ago

Do other PDF Viewers even support something like this, since this really does seem like something that could add a whole bunch of additional complexity to the find implementation!?

garydeng01 commented 1 month ago

Do you expect it to search also in annotations that are not open (those that only open when you pass the mouse on them), or in all of them?

This seems interesting and if the maintainers like the feature I will probably submit a PR at some point, but maybe it should be opt-in through a checkbox in the search bar,

For my use case, I would prefer that the search includes the popup annotations that are not open. Perhaps navigating to such a match would then open the popup and highlight the text within? I'm not sure what most users would prefer, but this seems like a reasonable way for it to function.