mozilla / pdf.js

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

How to perform a search without jumping to search results #13496

Closed adambeer closed 3 years ago

adambeer commented 3 years ago

I am using ngx-extended-pdf-viewer and have dug around to find that I need to ask this question here. How can I perform a search (I'm just trying to get highlights) and not shift the viewer to the (closest?) search result?

I currently have to implement some really hacky solutions to shift the viewer back to the intended page but havent been able to get an acceptable result. Im guessing the proper solution is to just disable the scrolling movements from calling find()?

Snuffleupagus commented 3 years ago

Duplicate of #4880

Snuffleupagus commented 3 years ago

To disable all scrolling, when searching, it should suffice to simply remove or comment out: https://github.com/mozilla/pdf.js/blob/e0676ec298e31dc4121578f80f246aa17e684ff9/web/pdf_find_controller.js#L727-L728

Although, please keep in mind that by disabling all scrolling, the following code also won't run and consequently there won't be any highlights on pages that are not already visible: https://github.com/mozilla/pdf.js/blob/e0676ec298e31dc4121578f80f246aa17e684ff9/web/pdf_find_controller.js#L560-L565

adambeer commented 3 years ago

@Snuffleupagus Thanks for the information! I can see this works with the example viewer but when I try to use the newly compiled files with ngx-extended-pdf-viewer, im not seeing this change anymore. Will the code above only affect the viewer and not the other files that other viewers like ngx-extended-pdf-viewer would rely on?

Snuffleupagus commented 3 years ago

[...] but when I try to use the newly compiled files with ngx-extended-pdf-viewer, im not seeing this change anymore.

Please note that that's a different project which, while it may be based on the PDF.js library, we don't really know anything about here and consequently can't provide any support for.

stephanrauh commented 3 years ago

@Snuffleupagus When someone mentions ngx-extended-pdf-viewer, just send them to me.

BTW: The code of ngx-extended-pdf-viewer is based on pdf.js, but it's using a custom fork that's slowly but steadily diverging from pdf.js. In particular, I might implement the feature @adambeer is looking for.