]> git.parisson.com Git - pdf.js.git/commitdiff
an-open-web document outline and bookmarks
authornotmasteryet <async.processingjs@yahoo.com>
Tue, 30 Aug 2011 01:59:38 +0000 (20:59 -0500)
committernotmasteryet <async.processingjs@yahoo.com>
Tue, 30 Aug 2011 01:59:38 +0000 (20:59 -0500)
pdf.js
web/viewer.js

diff --git a/pdf.js b/pdf.js
index 201744efecac38ee1573d95ac132f1543309dea1..bf0cf50c1da158046b5506aef7b06b16b6e76b3a 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -3541,6 +3541,11 @@ var Catalog = (function() {
       }
     },
     get destinations() {
+      function fetchDestination(ref) {
+        var dest = xref.fetchIfRef(ref);
+        return IsDict(dest) ? dest.get('D') : dest;
+      }
+
       var xref = this.xref;
       var dests = {}, nameTreeRef, nameDictionaryRef;
       var obj = this.catDict.get('Names');
@@ -3551,10 +3556,10 @@ var Catalog = (function() {
 
       if (nameDictionaryRef) {
         // reading simple destination dictionary
-        obj = xref.fetch(nameDictionaryRef);
+        obj = xref.fetchIfRef(nameDictionaryRef);
         obj.forEach(function(key, value) {
           if (!value) return;
-          dests[key] = xref.fetch(value).get('D');
+          dests[key] = fetchDestination(value);
         });
       }
       if (nameTreeRef) {
@@ -3578,8 +3583,7 @@ var Catalog = (function() {
           }
           var names = obj.get('Names');
           for (i = 0, n = names.length; i < n; i += 2) {
-            var dest = xref.fetch(names[i + 1]);
-            dests[names[i]] = IsDict(dest) ? dest.get('D') : dest;
+            dests[names[i]] = fetchDestination(names[i + 1]);
           }
         }
       }
index 243afb7e5248d0beba7490f1cae79624cf8c64c5..b07408bc0fdd6fc445a25b607bb18f184f4affb8 100644 (file)
@@ -91,7 +91,8 @@ var PDFView = {
       return; // invalid destination
     // dest array looks like that: <page-ref> </XYZ|FitXXX> <args..>
     var destRef = dest[0];
-    var pageNumber = this.pagesRefMap[destRef.num + ' ' + destRef.gen + ' R'];
+    var pageNumber = destRef instanceof Object ?
+      this.pagesRefMap[destRef.num + ' ' + destRef.gen + ' R'] : (destRef + 1);
     if (pageNumber) {
       this.page = pageNumber;
       // TODO scroll to specific region on the page, the precise scaling