From b1f50747b26e50735b75f476fa30e3bbe27bbba9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Bu=CC=88tzer?= Date: Wed, 6 Apr 2016 12:11:24 +0200 Subject: [PATCH] Fix rounding errors for Acroform elements --- plugins/acroform.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/plugins/acroform.js b/plugins/acroform.js index 354b2c159..11d25b67e 100644 --- a/plugins/acroform.js +++ b/plugins/acroform.js @@ -1581,32 +1581,32 @@ AcroForm.internal.calculateCoordinates = function (x, y, w, h) { x[2] = AcroForm.scale(x[2]); x[3] = AcroForm.scale(x[3]); - coordinates.lowerLeft_X = x[0] | 0; - coordinates.lowerLeft_Y = (mmtopx.call(this, this.internal.pageSize.height) - x[3] - x[1]) | 0; - coordinates.upperRight_X = x[0] + x[2] | 0; - coordinates.upperRight_Y = (mmtopx.call(this, this.internal.pageSize.height) - x[1]) | 0; + coordinates.lowerLeft_X = x[0] || 0; + coordinates.lowerLeft_Y = (mmtopx.call(this, this.internal.pageSize.height) - x[3] - x[1]) || 0; + coordinates.upperRight_X = x[0] + x[2] || 0; + coordinates.upperRight_Y = (mmtopx.call(this, this.internal.pageSize.height) - x[1]) || 0; } else { x = AcroForm.scale(x); y = AcroForm.scale(y); w = AcroForm.scale(w); h = AcroForm.scale(h); - coordinates.lowerLeft_X = x | 0; - coordinates.lowerLeft_Y = this.internal.pageSize.height - y | 0; - coordinates.upperRight_X = x + w | 0; - coordinates.upperRight_Y = this.internal.pageSize.height - y + h | 0; + coordinates.lowerLeft_X = x || 0; + coordinates.lowerLeft_Y = this.internal.pageSize.height - y || 0; + coordinates.upperRight_X = x + w || 0; + coordinates.upperRight_Y = this.internal.pageSize.height - y + h || 0; } } else { // old method, that is fallback, if we can't get the pageheight, the coordinate-system starts from lower left if (Array.isArray(x)) { - coordinates.lowerLeft_X = x[0] | 0; - coordinates.lowerLeft_Y = x[1] | 0; - coordinates.upperRight_X = x[0] + x[2] | 0; - coordinates.upperRight_Y = x[1] + x[3] | 0; + coordinates.lowerLeft_X = x[0] || 0; + coordinates.lowerLeft_Y = x[1] || 0; + coordinates.upperRight_X = x[0] + x[2] || 0; + coordinates.upperRight_Y = x[1] + x[3] || 0; } else { - coordinates.lowerLeft_X = x | 0; - coordinates.lowerLeft_Y = y | 0; - coordinates.upperRight_X = x + w | 0; - coordinates.upperRight_Y = y + h | 0; + coordinates.lowerLeft_X = x || 0; + coordinates.lowerLeft_Y = y || 0; + coordinates.upperRight_X = x + w || 0; + coordinates.upperRight_Y = y + h || 0; } }