1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-23 08:38:06 +02:00

Merge pull request #19066 from jarklee/issue19056

Fix #serializeBoxes function not output correct quadPoints values for deserialize (issue19056)
This commit is contained in:
calixteman 2024-11-29 18:31:28 +01:00 committed by GitHub
commit 9ecc613c08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 8 deletions

View file

@ -749,15 +749,14 @@ class HighlightEditor extends AnnotationEditor {
let i = 0;
for (const { x, y, width, height } of boxes) {
const sx = x * pageWidth + pageX;
const sy = (1 - y - height) * pageHeight + pageY;
// The specifications say that the rectangle should start from the bottom
// left corner and go counter-clockwise.
// But when opening the file in Adobe Acrobat it appears that this isn't
// correct hence the 4th and 6th numbers are just swapped.
const sy = (1 - y) * pageHeight + pageY;
// Serializes the rectangle in the Adobe Acrobat format.
// The rectangle's coordinates (b = bottom, t = top, L = left, R = right)
// are ordered as follows: tL, tR, bL, bR (bL origin).
quadPoints[i] = quadPoints[i + 4] = sx;
quadPoints[i + 1] = quadPoints[i + 3] = sy;
quadPoints[i + 2] = quadPoints[i + 6] = sx + width * pageWidth;
quadPoints[i + 5] = quadPoints[i + 7] = sy + height * pageHeight;
quadPoints[i + 5] = quadPoints[i + 7] = sy - height * pageHeight;
i += 8;
}
return quadPoints;