]> git.parisson.com Git - pdf.js.git/commitdiff
Normalizing rotation
authorBrendan Dahl <brendan.dahl@gmail.com>
Mon, 8 Aug 2011 04:54:11 +0000 (21:54 -0700)
committerBrendan Dahl <brendan.dahl@gmail.com>
Mon, 8 Aug 2011 04:54:11 +0000 (21:54 -0700)
pdf.js

diff --git a/pdf.js b/pdf.js
index 57d8ffd22e025b0e50510b0a3bfd052574fdde03..3642ad6284b32213409b226b649fb271049eabff 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -3038,6 +3038,16 @@ var Page = (function() {
     },
     get rotate() {
       var rotate = this.inheritPageProp("Rotate") || 0;
+      // Normalize rotation so it's a multiple of 90 and between 0 and 270
+      if (rotate % 90 != 0) {
+        rotate = 0;
+      } else if (rotate >= 360) {
+        rotate = rotate % 360;
+      } else if (rotate < 0) {
+        // The spec doesn't cover negatives, assume its counterclockwise
+        // rotation. The following is the other implementation of modulo.
+        rotate = ((rotate % 360) + 360) % 360;
+      }
       return shadow(this, 'rotate', rotate);
     },
     startRendering: function(canvasCtx, continuation, onerror) {