Skip to content

Commit b5d5339

Browse files
committed
Merge pull request #730 from renuo/fix/acroform-rounding-error
Fix rounding errors for Acroform elements
2 parents aec8db1 + b1f5074 commit b5d5339

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

plugins/acroform.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,32 +1581,32 @@ AcroForm.internal.calculateCoordinates = function (x, y, w, h) {
15811581
x[2] = AcroForm.scale(x[2]);
15821582
x[3] = AcroForm.scale(x[3]);
15831583

1584-
coordinates.lowerLeft_X = x[0] | 0;
1585-
coordinates.lowerLeft_Y = (mmtopx.call(this, this.internal.pageSize.height) - x[3] - x[1]) | 0;
1586-
coordinates.upperRight_X = x[0] + x[2] | 0;
1587-
coordinates.upperRight_Y = (mmtopx.call(this, this.internal.pageSize.height) - x[1]) | 0;
1584+
coordinates.lowerLeft_X = x[0] || 0;
1585+
coordinates.lowerLeft_Y = (mmtopx.call(this, this.internal.pageSize.height) - x[3] - x[1]) || 0;
1586+
coordinates.upperRight_X = x[0] + x[2] || 0;
1587+
coordinates.upperRight_Y = (mmtopx.call(this, this.internal.pageSize.height) - x[1]) || 0;
15881588
} else {
15891589
x = AcroForm.scale(x);
15901590
y = AcroForm.scale(y);
15911591
w = AcroForm.scale(w);
15921592
h = AcroForm.scale(h);
1593-
coordinates.lowerLeft_X = x | 0;
1594-
coordinates.lowerLeft_Y = this.internal.pageSize.height - y | 0;
1595-
coordinates.upperRight_X = x + w | 0;
1596-
coordinates.upperRight_Y = this.internal.pageSize.height - y + h | 0;
1593+
coordinates.lowerLeft_X = x || 0;
1594+
coordinates.lowerLeft_Y = this.internal.pageSize.height - y || 0;
1595+
coordinates.upperRight_X = x + w || 0;
1596+
coordinates.upperRight_Y = this.internal.pageSize.height - y + h || 0;
15971597
}
15981598
} else {
15991599
// old method, that is fallback, if we can't get the pageheight, the coordinate-system starts from lower left
16001600
if (Array.isArray(x)) {
1601-
coordinates.lowerLeft_X = x[0] | 0;
1602-
coordinates.lowerLeft_Y = x[1] | 0;
1603-
coordinates.upperRight_X = x[0] + x[2] | 0;
1604-
coordinates.upperRight_Y = x[1] + x[3] | 0;
1601+
coordinates.lowerLeft_X = x[0] || 0;
1602+
coordinates.lowerLeft_Y = x[1] || 0;
1603+
coordinates.upperRight_X = x[0] + x[2] || 0;
1604+
coordinates.upperRight_Y = x[1] + x[3] || 0;
16051605
} else {
1606-
coordinates.lowerLeft_X = x | 0;
1607-
coordinates.lowerLeft_Y = y | 0;
1608-
coordinates.upperRight_X = x + w | 0;
1609-
coordinates.upperRight_Y = y + h | 0;
1606+
coordinates.lowerLeft_X = x || 0;
1607+
coordinates.lowerLeft_Y = y || 0;
1608+
coordinates.upperRight_X = x + w || 0;
1609+
coordinates.upperRight_Y = y + h || 0;
16101610
}
16111611
}
16121612

0 commit comments

Comments
 (0)