You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using the current beta version (pdfjs-2.6.347-dist).
I traced the bug to incorrect code for negating numbers by pasting a hyphen on the front of the string, rather than actually negating the numbers. Pasting a hyphen in front of a negative number like -3 gives you --3 instead of 3.
It's certainly possible for link (and other annotation) bounds can be negative (ie, beyond the top/left edge of the page). The current pdf.js code offsets such regions significantly from where they should be. The following patch fixes this bug and a related bug, and also adds a few lines to clip the regions so that they are within the page so they look neater.
The following patch fixes this bug and a related bug, and also adds a few lines to clip the regions so that they are within the page so they look neater.
Finally, also keep in mind that it's always best to have non-related changes in separate commits (although they can obviously be in the same PR).
I'm using the current beta version (pdfjs-2.6.347-dist).
I traced the bug to incorrect code for negating numbers by pasting a hyphen on the front of the string, rather than actually negating the numbers. Pasting a hyphen in front of a negative number like -3 gives you --3 instead of 3.
It's certainly possible for link (and other annotation) bounds can be negative (ie, beyond the top/left edge of the page). The current pdf.js code offsets such regions significantly from where they should be. The following patch fixes this bug and a related bug, and also adds a few lines to clip the regions so that they are within the page so they look neater.
--- pdf.js (revision 1225)
+++ pdf.js (working copy)
@@ -9374,14 +9374,18 @@
page = this.page,
viewport = this.viewport;
const container = document.createElement("section");
let width = data.rect[2] - data.rect[0];
let height = data.rect[3] - data.rect[1];
container.setAttribute("data-annotation-id", data.id);
const rect = _util.Util.normalizeRect([data.rect[0], page.view[3] - data.rect[1] + page.view[1], data.rect[2], page.view[3] - data.rect[3] + page.view[1]]);
if( rect[0] < page.view[0] ) rect[0] = page.view[0]; else if( rect[0] > page.view[2] ) rect[0] = page.view[2];
if( rect[1] < page.view[1] ) rect[1] = page.view[1]; else if( rect[1] > page.view[3] ) rect[1] = page.view[3];
if( rect[2] < page.view[0] ) rect[2] = page.view[0]; else if( rect[2] > page.view[2] ) rect[2] = page.view[2];
if( rect[3] < page.view[1] ) rect[3] = page.view[1]; else if( rect[3] > page.view[3] ) rect[3] = page.view[3];
let width = rect[2] - rect[0];
let height = rect[3] - rect[1];
container.style.transform =
matrix(${viewport.transform.join(",")})
;-${rect[0]}px -${rect[1]}px
;container.style.transformOrigin =
${-rect[0]}px ${-rect[1]}px
;if (!ignoreBorder && data.borderStyle.width > 0) {
container.style.borderWidth =
${data.borderStyle.width}px
;@@ -9801,7 +9805,7 @@
});
const parentLeft = parseFloat(parentElement.style.left);
const parentWidth = parseFloat(parentElement.style.width);
-${parentLeft + parentWidth}px -${parentElement.style.top}
;${-(parentLeft + parentWidth)}px ${-parentElement.style.top}
;this.container.style.left =
${parentLeft + parentWidth}px
;this.container.appendChild(popup.render());
return this.container;
The text was updated successfully, but these errors were encountered: