diff --git a/pdf.js b/pdf.js index 0b810a3ee..9a0b0977a 100644 --- a/pdf.js +++ b/pdf.js @@ -2415,7 +2415,7 @@ var Lexer = (function() { } constructor.isSpace = function(ch) { - return ch == ' ' || ch == '\t' || ch == '\x0d'; + return ch == ' ' || ch == '\t' || ch == '\x0d' || ch == '\x0a'; }; // A '1' in this array means the character is white space. A '1' or @@ -3094,10 +3094,11 @@ var XRef = (function() { // check for 'XRefStm' key if (IsInt(obj = dict.get('XRefStm'))) { var pos = obj; - if (pos in this.xrefstms) - error('Invalid XRef table'); - this.xrefstms[pos] = 1; // avoid infinite recursion - this.readXRef(pos); + // ignore previously loaded xref streams (possible infinite recursion) + if (!(pos in this.xrefstms)) { + this.xrefstms[pos] = 1; + this.readXRef(pos); + } } return dict; @@ -4184,7 +4185,7 @@ var PartialEvaluator = (function() { if (typeNum == 1) { patternName.code = this.evaluate(pattern, xref, dict.get('Resources'), - fonts); + fonts, images); } } } @@ -4324,14 +4325,16 @@ var PartialEvaluator = (function() { baseEncoding = Encodings[baseName.name].slice(); // Load the differences between the base and original - var diffEncoding = encoding.get('Differences'); - var index = 0; - for (var j = 0; j < diffEncoding.length; j++) { - var data = diffEncoding[j]; - if (IsNum(data)) - index = data; - else - differences[index++] = data.name; + if (encoding.has('Differences')) { + var diffEncoding = encoding.get('Differences'); + var index = 0; + for (var j = 0; j < diffEncoding.length; j++) { + var data = diffEncoding[j]; + if (IsNum(data)) + index = data; + else + differences[index++] = data.name; + } } } else if (IsName(encoding)) { baseEncoding = Encodings[encoding.name].slice(); diff --git a/test/pdfs/f1040.pdf.link b/test/pdfs/f1040.pdf.link new file mode 100644 index 000000000..a3299fc54 --- /dev/null +++ b/test/pdfs/f1040.pdf.link @@ -0,0 +1 @@ +http://www.irs.gov/pub/irs-pdf/f1040.pdf diff --git a/test/pdfs/txt2pdf.pdf.link b/test/pdfs/txt2pdf.pdf.link new file mode 100644 index 000000000..09653f39c --- /dev/null +++ b/test/pdfs/txt2pdf.pdf.link @@ -0,0 +1 @@ +http://www.sanface.com/pdf/test.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index 44955eefa..edf13b7c5 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -133,5 +133,17 @@ "link": true, "rounds": 1, "type": "load" + }, + { "id": "txt2pdf", + "file": "pdfs/txt2pdf.pdf", + "link": true, + "rounds": 1, + "type": "load" + }, + { "id": "f1040", + "file": "pdfs/f1040.pdf", + "link": true, + "rounds": 1, + "type": "load" } ] diff --git a/web/viewer.css b/web/viewer.css index d1f725a02..cda191a76 100644 --- a/web/viewer.css +++ b/web/viewer.css @@ -271,3 +271,8 @@ canvas { page-break-after: always; } } + +#loading { + margin: 100px 0; + text-align: center; +} diff --git a/web/viewer.html b/web/viewer.html index 00950a44c..e22cacbf6 100644 --- a/web/viewer.html +++ b/web/viewer.html @@ -90,7 +90,8 @@ - + +