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

Fix annotation layer misalignment issue #256

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kevin-lynch
Copy link

@kevin-lynch kevin-lynch commented Oct 8, 2020

Set ratio to 1. Any other value causes unexpected alignment issues of the annotation layer, specifically some instances in windows 10 google chrome. Tested on multiple devices, this fix has no issues.

@@ -199,7 +199,7 @@ export default function(PDFJS) {

var pageRotate = (pdfPage.rotate === undefined ? 0 : pdfPage.rotate) + (rotate === undefined ? 0 : rotate);

var scale = canvasElt.offsetWidth / pdfPage.getViewport({ scale: 1 }).width * (window.devicePixelRatio || 1);
var scale = canvasElt.offsetWidth / pdfPage.getViewport({ scale: 1 }).width * 1;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably not going to be merged as the owner doesn't seem to be active on this package.

However, there is no point to multiply by 1, if window.devicePixelRatio is creating problems you might just remove the multiplication.

so instead of * 1 you just write:

var scale = canvasElt.offsetWidth / pdfPage.getViewport({ scale: 1 }).width

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your input. I did try this originally and it didn't always fix the issue in some edge cases. 1 is the second condition, it multiplies by window.devicePixelRatio if the relevant condition is met.

@andorfermichael
Copy link

@FranckFreiburger would be really great if this issue would be fixed.

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

Successfully merging this pull request may close these issues.

None yet

3 participants