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

[Regression] Initial textLayer rendering not correct after PR 15722 #15795

Closed
Snuffleupagus opened this issue Dec 8, 2022 · 2 comments · Fixed by #15796
Closed

[Regression] Initial textLayer rendering not correct after PR 15722 #15795

Snuffleupagus opened this issue Dec 8, 2022 · 2 comments · Fixed by #15796
Assignees
Labels

Comments

@Snuffleupagus
Copy link
Collaborator

Attach (recommended) or Link to PDF file here:

Configuration:

Steps to reproduce the problem:
After PR #15722, the textLayer will no longer have correct dimensions unless zooming has occurred at least once. This was found when testing the "pageviewer" component-example locally, see https://github.com/mozilla/pdf.js/tree/master/examples/components

To more easily reproduce this directly in the default viewer, apply the following diff and load http://localhost:8888/web/viewer.html#disableHistory=true&textLayer=visible:

diff --git a/web/app.js b/web/app.js
index e79ba7b5c..2d37c9319 100644
--- a/web/app.js
+++ b/web/app.js
@@ -1638,8 +1638,9 @@ const PDFViewerApplication = {
     if (!this.pdfViewer.currentScaleValue) {
       // Scale was not initialized: invalid bookmark or scale was not specified
.
       // Setting the default one.
-      this.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
+      // this.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
     }
+    this.pdfViewer.update();
   },

What is the expected behavior? (add screenshot)
Correct initial textLayer dimensions, as in:

working

What went wrong? (add screenshot)
Wrong initial textLayer dimensions, as in:

broken

Link to a viewer (if hosted on a site other than mozilla.github.io/pdf.js or as Firefox/Chrome extension): N/A

/cc @calixteman

@Snuffleupagus
Copy link
Collaborator Author

One way to address this may be to always set the following by default in the PDFViewer/PDFPageView constructors, so if that makes sense overall I can submit a patch!

docStyle.setProperty("--scale-factor", PixelsPerInch.PDF_TO_CSS_UNITS);

@calixteman
Copy link
Contributor

Yep it's what I found too (i.e. the fact that the scale-factor is wrong).
I'd say that this bug just highlights something which was already wrong.
Let's go for your fix :).

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