From 850c042af75f8a1d3d3d8f788c3f27b508bf3f4c Mon Sep 17 00:00:00 2001 From: Brendan Dahl Date: Sun, 7 Aug 2011 21:54:11 -0700 Subject: [PATCH] Normalizing rotation --- pdf.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pdf.js b/pdf.js index 57d8ffd22..3642ad628 100644 --- 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) {