]> git.parisson.com Git - pdf.js.git/commitdiff
hand in xref to the parser if needed so we can resolve 'Length' for sub-streams
authorAndreas Gal <andreas.gal@gmail.com>
Fri, 3 Jun 2011 21:38:54 +0000 (14:38 -0700)
committerAndreas Gal <andreas.gal@gmail.com>
Fri, 3 Jun 2011 21:38:54 +0000 (14:38 -0700)
pdf.js

diff --git a/pdf.js b/pdf.js
index 3fc418211fa1df6ef0a4dca346a3f86d98ea7ef2..6d1e50748d5ad2d0e7fbc89c9dc7f6649a05e1f4 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -1402,9 +1402,10 @@ var Lexer = (function() {
 })();
 
 var Parser = (function() {
-    function constructor(lexer, allowStreams) {
+    function constructor(lexer, allowStreams, xref) {
         this.lexer = lexer;
         this.allowStreams = allowStreams;
+        this.xref = xref;
         this.inlineImg = 0;
         this.refill();
     }
@@ -1513,8 +1514,11 @@ var Parser = (function() {
             var pos = stream.pos;
             
             // get length
-            var length;
-            if (!IsInt(length = dict.get("Length"))) {
+            var length = dict.get("Length");
+            var xref = this.xref;
+            if (xref)
+                length = xref.fetchIfRef(length);
+            if (!IsInt(length)) {
                 error("Bad 'Length' attribute in stream");
                 lenght = 0;
             }
@@ -1783,7 +1787,7 @@ var XRef = (function() {
                 if (e.gen != gen)
                     throw("inconsistent generation in XRef");
                 var stream = this.stream.makeSubStream(e.offset);
-                var parser = new Parser(new Lexer(stream), true);
+                var parser = new Parser(new Lexer(stream), true, this);
                 var obj1 = parser.getObj();
                 var obj2 = parser.getObj();
                 var obj3 = parser.getObj();