Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Scroll to search result doesn't take into account text layer horizontal scaling #19207

Open
nicolo-ribaudo opened this issue Dec 10, 2024 · 0 comments

Comments

@nicolo-ribaudo
Copy link
Contributor

nicolo-ribaudo commented Dec 10, 2024

Attach (recommended) or Link to PDF file

large_pdf_test-3.pdf

This wide PDF with a wide font is just because it makes it easy to see the problem on desktop, but I first noticed it in Android WebView with a normal PDF (where my phone enforces a minimum text size, and thus the text layer needs to be significantly scaled).

Web browser and its version

Firefox 133.0, but also seen in Chrome

Operating system and its version

Not relevat

PDF.js version

Latest

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

Yes

Is a browser extension

No

Steps to reproduce the problem

  1. Open the above PDF
  2. Set the zoom to 200%
  3. Search for "40"

What is the expected behavior?

It finds a match, and it should show the match on screen.

If you scroll to 40 you'll see it highlighted (note that the text layer is misaligned by a few character in this example PDF, but assume that it was actually well aligned :P)

What went wrong?

It depends on the exact screen size, but I'm seeing only the numbers from 9 to 23.

Link to a viewer

No response

Additional context

This happens whenever there is a significant (either much larger than 1, or much smaller) scaleX applied to the text layer, because we compute the horizontal offset using .offsetLeft that does not take into account CSS scaling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants