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

Pages with viewbox coordinates where max<min have no text #15801

Closed
Deco opened this issue Dec 10, 2022 · 2 comments
Closed

Pages with viewbox coordinates where max<min have no text #15801

Deco opened this issue Dec 10, 2022 · 2 comments

Comments

@Deco
Copy link

Deco commented Dec 10, 2022

Attach (recommended) or Link to PDF file here: It contains semi-private information. I can send directly to any dev willing to tackle this issue.

Configuration:

  • Web browser and its version: NodeJS
  • Operating system and its version: Windows 10 & Ubuntu
  • PDF.js version: 3.1.81
  • Is a browser extension: No

Steps to reproduce the problem:

  1. Find a PDF that uses a viewport like (0, 0, 100, -200).
  2. Notice that all text is treated as "outside the viewbox" (even though a coordinate like 50,-100 is completely valid in this situation)

What is the expected behavior? The text is treated as inside the page.

What went wrong? All text is treated as outside the page.


The problem was introduced by this new code in this commit:
18e3a98#diff-cf40014d9c7d352f3ae212e7fffe5386decf96a10e53066a4d900c3eb8fc559eR2404

The if-statement here has a naively-written condition that does not handle the case where the viewbox minimum is numerically greater than the viewbox maximum on the same axis. I believe the correct code would be:

    function compareWithLastPosition() {
      const currentTransform = getCurrentTextTransform();
      let posX = currentTransform[4];
      let posY = currentTransform[5];

      if (
        posX < Math.min(viewBox[0], viewBox[2]) ||
        posX > Math.max(viewBox[0], viewBox[2]) ||
        posY < Math.min(viewBox[1], viewBox[3]) ||
        posY > Math.max(viewBox[1], viewBox[3])
      ) {
        return false;
      }
      
      // ...
@Deco Deco changed the title Pages with negative viewport coordinates have no text Pages with viewport coordinates where max<min have no text Dec 10, 2022
@Deco Deco changed the title Pages with viewport coordinates where max<min have no text Pages with viewbox coordinates where max<min have no text Dec 10, 2022
@Snuffleupagus
Copy link
Collaborator

Given that lack of a test-case, I'm guessing that this was fixed by PR #15773.

@Deco
Copy link
Author

Deco commented Dec 10, 2022

I'll check and let you know -- thanks @Snuffleupagus!

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