Skip to content

Fix annotation layer misalignment issue #256

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pdfjsWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.

var viewport = pdfPage.getViewport({ scale: scale, rotation:pageRotate });

emitEvent('page-size', viewport.width, viewport.height, scale);
Expand Down