From c20476bfca87c3ef43e03303f57633db10ce8511 Mon Sep 17 00:00:00 2001
From: Brendan Dahl <brendan.dahl@gmail.com>
Date: Mon, 25 Nov 2013 10:05:23 -0800
Subject: [PATCH] Fix page rotation for unloaded pages.

---
 web/page_view.js | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/web/page_view.js b/web/page_view.js
index e28d8bfa7..b4783e7da 100644
--- a/web/page_view.js
+++ b/web/page_view.js
@@ -54,11 +54,19 @@ var PageView = function pageView(container, id, scale,
   this.setPdfPage = function pageViewSetPdfPage(pdfPage) {
     this.pdfPage = pdfPage;
     this.pdfPageRotate = pdfPage.rotate;
-    this.viewport = pdfPage.getViewport(this.scale * CSS_UNITS);
+    this.updateViewport();
     this.stats = pdfPage.stats;
     this.reset();
   };
 
+  this.updateViewport = function pageViewUpdateViewport() {
+    var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
+    this.viewport = this.viewport.clone({
+      scale: this.scale * CSS_UNITS,
+      rotation: totalRotation
+    });
+  },
+
   this.destroy = function pageViewDestroy() {
     this.zoomLayer = null;
     this.reset();
@@ -103,11 +111,7 @@ var PageView = function pageView(container, id, scale,
       this.rotation = rotation;
     }
 
-    var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
-    this.viewport = this.viewport.clone({
-      scale: this.scale * CSS_UNITS,
-      rotation: totalRotation
-    });
+    this.updateViewport();
 
     if (USE_ONLY_CSS_ZOOM && this.canvas) {
       this.cssTransform(this.canvas);