Skip to content

[Bug]: search / find - bad scroll position, weird stepping #18769

@rossj

Description

@rossj

Attach (recommended) or Link to PDF file

bad match scrolling & stepping.pdf

Web browser and its version

Chrome 129, Firefox 130

Operating system and its version

WIndows 11

PDF.js version

4.6.82

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

Yes

Is a browser extension

No

Steps to reproduce the problem

  1. Open the problem document in demo viewer
  2. Initiate a "Find in Document" for "Page1"

What is the expected behavior?

The highlighted match on page 1 should be scrolled into view (if not already).

What went wrong?

The document scrolls to show the middle of page 2 at the top, with the highlighted match out of view.

Link to a viewer

No response

Additional context

I came across a problematic document where the "Find in Document" feature was always scrolling a page or more past the highlighted match. I was able to create this sample document by editing / scrubbing the original document using Acrobat.

Notice that with this sample document, searches for "Page1", "Page2", "Page3", always scroll to middle of the next page. Searches for "Page4" and "Page5" would likely behave similarly, except we reach the max scroll at the end of the document.

This document also exhibits strange "next" / "previous" find behavior, which may be related to the same scroll offset issue. Initiating a search for just "Page" correctly identifies 5 matches, but cycling forward goes from "1 of 5" to "3 of 5" to "5 of 5", and skips "2 of 5" and "4 of 5". Cycling backwards goes from "5 of 5" to "4 of 5" to "3 of 5" and then back to "5 of 5", skipping "2 of 5" and "1 of 5".

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions