Skip to content
Snippets Groups Projects
1.index.js 1.51 MiB
Newer Older
  • Learn to ignore specific revisions
  • 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 12203 12204 12205 12206 12207 12208 12209 12210 12211 12212 12213 12214 12215 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 12251 12252 12253 12254 12255 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 12285 12286 12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 12424 12425 12426 12427 12428 12429 12430 12431 12432 12433 12434 12435 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 12488 12489 12490 12491 12492 12493 12494 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 12507 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 12531 12532 12533 12534 12535 12536 12537 12538 12539 12540 12541 12542 12543 12544 12545 12546 12547 12548 12549 12550 12551 12552 12553 12554 12555 12556 12557 12558 12559 12560 12561 12562 12563 12564 12565 12566 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 12603 12604 12605 12606 12607 12608 12609 12610 12611 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 12627 12628 12629 12630 12631 12632 12633 12634 12635 12636 12637 12638 12639 12640 12641 12642 12643 12644 12645 12646 12647 12648 12649 12650 12651 12652 12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 12663 12664 12665 12666 12667 12668 12669 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 12680 12681 12682 12683 12684 12685 12686 12687 12688 12689 12690 12691 12692 12693 12694 12695 12696 12697 12698 12699 12700 12701 12702 12703 12704 12705 12706 12707 12708 12709 12710 12711 12712 12713 12714 12715 12716 12717 12718 12719 12720 12721 12722 12723 12724 12725 12726 12727 12728 12729 12730 12731 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 12746 12747 12748 12749 12750 12751 12752 12753 12754 12755 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 12767 12768 12769 12770 12771 12772 12773 12774 12775 12776 12777 12778 12779 12780 12781 12782 12783 12784 12785 12786 12787 12788 12789 12790 12791 12792 12793 12794 12795 12796 12797 12798 12799 12800 12801 12802 12803 12804 12805 12806 12807 12808 12809 12810 12811 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 12822 12823 12824 12825 12826 12827 12828 12829 12830 12831 12832 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 12850 12851 12852 12853 12854 12855 12856 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 12877 12878 12879 12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12929 12930 12931 12932 12933 12934 12935 12936 12937 12938 12939 12940 12941 12942 12943 12944 12945 12946 12947 12948 12949 12950 12951 12952 12953 12954 12955 12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000
            }, this.capability.reject);
            return;
          }
          this.refSet = null;
          this.capability.resolve();
        }
      };
      return ObjectLoader;
    }();
    exports.Catalog = Catalog;
    exports.ObjectLoader = ObjectLoader;
    exports.XRef = XRef;
    exports.FileSpec = FileSpec;
    
    /***/ }),
    /* 138 */
    /***/ (function(module, exports, __w_pdfjs_require__) {
    
    "use strict";
    
    
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    
    var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
    
    var EOF = {};
    var Name = function NameClosure() {
      function Name(name) {
        this.name = name;
      }
      Name.prototype = {};
      var nameCache = Object.create(null);
      Name.get = function Name_get(name) {
        var nameValue = nameCache[name];
        return nameValue ? nameValue : nameCache[name] = new Name(name);
      };
      return Name;
    }();
    var Cmd = function CmdClosure() {
      function Cmd(cmd) {
        this.cmd = cmd;
      }
      Cmd.prototype = {};
      var cmdCache = Object.create(null);
      Cmd.get = function Cmd_get(cmd) {
        var cmdValue = cmdCache[cmd];
        return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
      };
      return Cmd;
    }();
    var Dict = function DictClosure() {
      var nonSerializable = function nonSerializableClosure() {
        return nonSerializable;
      };
      function Dict(xref) {
        this._map = Object.create(null);
        this.xref = xref;
        this.objId = null;
        this.suppressEncryption = false;
        this.__nonSerializable__ = nonSerializable;
      }
      Dict.prototype = {
        assignXref: function Dict_assignXref(newXref) {
          this.xref = newXref;
        },
        get: function Dict_get(key1, key2, key3) {
          var value;
          var xref = this.xref,
              suppressEncryption = this.suppressEncryption;
          if (typeof (value = this._map[key1]) !== 'undefined' || key1 in this._map || typeof key2 === 'undefined') {
            return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
          }
          if (typeof (value = this._map[key2]) !== 'undefined' || key2 in this._map || typeof key3 === 'undefined') {
            return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
          }
          value = this._map[key3] || null;
          return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
        },
        getAsync: function Dict_getAsync(key1, key2, key3) {
          var value;
          var xref = this.xref,
              suppressEncryption = this.suppressEncryption;
          if (typeof (value = this._map[key1]) !== 'undefined' || key1 in this._map || typeof key2 === 'undefined') {
            if (xref) {
              return xref.fetchIfRefAsync(value, suppressEncryption);
            }
            return Promise.resolve(value);
          }
          if (typeof (value = this._map[key2]) !== 'undefined' || key2 in this._map || typeof key3 === 'undefined') {
            if (xref) {
              return xref.fetchIfRefAsync(value, suppressEncryption);
            }
            return Promise.resolve(value);
          }
          value = this._map[key3] || null;
          if (xref) {
            return xref.fetchIfRefAsync(value, suppressEncryption);
          }
          return Promise.resolve(value);
        },
        getArray: function Dict_getArray(key1, key2, key3) {
          var value = this.get(key1, key2, key3);
          var xref = this.xref,
              suppressEncryption = this.suppressEncryption;
          if (!Array.isArray(value) || !xref) {
            return value;
          }
          value = value.slice();
          for (var i = 0, ii = value.length; i < ii; i++) {
            if (!isRef(value[i])) {
              continue;
            }
            value[i] = xref.fetch(value[i], suppressEncryption);
          }
          return value;
        },
        getRaw: function Dict_getRaw(key) {
          return this._map[key];
        },
        getKeys: function Dict_getKeys() {
          return Object.keys(this._map);
        },
        set: function Dict_set(key, value) {
          this._map[key] = value;
        },
        has: function Dict_has(key) {
          return key in this._map;
        },
        forEach: function Dict_forEach(callback) {
          for (var key in this._map) {
            callback(key, this.get(key));
          }
        }
      };
      Dict.empty = new Dict(null);
      Dict.merge = function (xref, dictArray) {
        var mergedDict = new Dict(xref);
        for (var i = 0, ii = dictArray.length; i < ii; i++) {
          var dict = dictArray[i];
          if (!isDict(dict)) {
            continue;
          }
          for (var keyName in dict._map) {
            if (mergedDict._map[keyName] !== undefined) {
              continue;
            }
            mergedDict._map[keyName] = dict._map[keyName];
          }
        }
        return mergedDict;
      };
      return Dict;
    }();
    var Ref = function RefClosure() {
      function Ref(num, gen) {
        this.num = num;
        this.gen = gen;
      }
      Ref.prototype = {
        toString: function Ref_toString() {
          var str = this.num + 'R';
          if (this.gen !== 0) {
            str += this.gen;
          }
          return str;
        }
      };
      return Ref;
    }();
    var RefSet = function RefSetClosure() {
      function RefSet() {
        this.dict = Object.create(null);
      }
      RefSet.prototype = {
        has: function RefSet_has(ref) {
          return ref.toString() in this.dict;
        },
        put: function RefSet_put(ref) {
          this.dict[ref.toString()] = true;
        },
        remove: function RefSet_remove(ref) {
          delete this.dict[ref.toString()];
        }
      };
      return RefSet;
    }();
    var RefSetCache = function RefSetCacheClosure() {
      function RefSetCache() {
        this.dict = Object.create(null);
      }
      RefSetCache.prototype = {
        get: function RefSetCache_get(ref) {
          return this.dict[ref.toString()];
        },
        has: function RefSetCache_has(ref) {
          return ref.toString() in this.dict;
        },
        put: function RefSetCache_put(ref, obj) {
          this.dict[ref.toString()] = obj;
        },
        putAlias: function RefSetCache_putAlias(ref, aliasRef) {
          this.dict[ref.toString()] = this.get(aliasRef);
        },
        forEach: function RefSetCache_forEach(fn, thisArg) {
          for (var i in this.dict) {
            fn.call(thisArg, this.dict[i]);
          }
        },
        clear: function RefSetCache_clear() {
          this.dict = Object.create(null);
        }
      };
      return RefSetCache;
    }();
    function isEOF(v) {
      return v === EOF;
    }
    function isName(v, name) {
      return v instanceof Name && (name === undefined || v.name === name);
    }
    function isCmd(v, cmd) {
      return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
    }
    function isDict(v, type) {
      return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
    }
    function isRef(v) {
      return v instanceof Ref;
    }
    function isRefsEqual(v1, v2) {
      return v1.num === v2.num && v1.gen === v2.gen;
    }
    function isStream(v) {
      return (typeof v === 'undefined' ? 'undefined' : _typeof(v)) === 'object' && v !== null && v.getBytes !== undefined;
    }
    exports.EOF = EOF;
    exports.Cmd = Cmd;
    exports.Dict = Dict;
    exports.Name = Name;
    exports.Ref = Ref;
    exports.RefSet = RefSet;
    exports.RefSetCache = RefSetCache;
    exports.isEOF = isEOF;
    exports.isCmd = isCmd;
    exports.isDict = isDict;
    exports.isName = isName;
    exports.isRef = isRef;
    exports.isRefsEqual = isRefsEqual;
    exports.isStream = isStream;
    
    /***/ }),
    /* 139 */
    /***/ (function(module, exports, __w_pdfjs_require__) {
    
    "use strict";
    
    
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.Parser = exports.Linearization = exports.Lexer = undefined;
    
    var _stream = __w_pdfjs_require__(140);
    
    var _util = __w_pdfjs_require__(2);
    
    var _primitives = __w_pdfjs_require__(138);
    
    var _ccitt_stream = __w_pdfjs_require__(141);
    
    var _jbig2_stream = __w_pdfjs_require__(143);
    
    var _jpeg_stream = __w_pdfjs_require__(146);
    
    var _jpx_stream = __w_pdfjs_require__(148);
    
    var MAX_LENGTH_TO_CACHE = 1000;
    var MAX_ADLER32_LENGTH = 5552;
    function computeAdler32(bytes) {
      var bytesLength = bytes.length;
      var a = 1,
          b = 0;
      for (var i = 0; i < bytesLength; ++i) {
        a += bytes[i] & 0xFF;
        b += a;
      }
      return b % 65521 << 16 | a % 65521;
    }
    var Parser = function ParserClosure() {
      function Parser(lexer, allowStreams, xref, recoveryMode) {
        this.lexer = lexer;
        this.allowStreams = allowStreams;
        this.xref = xref;
        this.recoveryMode = recoveryMode || false;
        this.imageCache = Object.create(null);
        this.refill();
      }
      Parser.prototype = {
        refill: function Parser_refill() {
          this.buf1 = this.lexer.getObj();
          this.buf2 = this.lexer.getObj();
        },
        shift: function Parser_shift() {
          if ((0, _primitives.isCmd)(this.buf2, 'ID')) {
            this.buf1 = this.buf2;
            this.buf2 = null;
          } else {
            this.buf1 = this.buf2;
            this.buf2 = this.lexer.getObj();
          }
        },
        tryShift: function Parser_tryShift() {
          try {
            this.shift();
            return true;
          } catch (e) {
            if (e instanceof _util.MissingDataException) {
              throw e;
            }
            return false;
          }
        },
        getObj: function Parser_getObj(cipherTransform) {
          var buf1 = this.buf1;
          this.shift();
          if (buf1 instanceof _primitives.Cmd) {
            switch (buf1.cmd) {
              case 'BI':
                return this.makeInlineImage(cipherTransform);
              case '[':
                var array = [];
                while (!(0, _primitives.isCmd)(this.buf1, ']') && !(0, _primitives.isEOF)(this.buf1)) {
                  array.push(this.getObj(cipherTransform));
                }
                if ((0, _primitives.isEOF)(this.buf1)) {
                  if (!this.recoveryMode) {
                    throw new _util.FormatError('End of file inside array');
                  }
                  return array;
                }
                this.shift();
                return array;
              case '<<':
                var dict = new _primitives.Dict(this.xref);
                while (!(0, _primitives.isCmd)(this.buf1, '>>') && !(0, _primitives.isEOF)(this.buf1)) {
                  if (!(0, _primitives.isName)(this.buf1)) {
                    (0, _util.info)('Malformed dictionary: key must be a name object');
                    this.shift();
                    continue;
                  }
                  var key = this.buf1.name;
                  this.shift();
                  if ((0, _primitives.isEOF)(this.buf1)) {
                    break;
                  }
                  dict.set(key, this.getObj(cipherTransform));
                }
                if ((0, _primitives.isEOF)(this.buf1)) {
                  if (!this.recoveryMode) {
                    throw new _util.FormatError('End of file inside dictionary');
                  }
                  return dict;
                }
                if ((0, _primitives.isCmd)(this.buf2, 'stream')) {
                  return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
                }
                this.shift();
                return dict;
              default:
                return buf1;
            }
          }
          if (Number.isInteger(buf1)) {
            var num = buf1;
            if (Number.isInteger(this.buf1) && (0, _primitives.isCmd)(this.buf2, 'R')) {
              var ref = new _primitives.Ref(num, this.buf1);
              this.shift();
              this.shift();
              return ref;
            }
            return num;
          }
          if ((0, _util.isString)(buf1)) {
            var str = buf1;
            if (cipherTransform) {
              str = cipherTransform.decryptString(str);
            }
            return str;
          }
          return buf1;
        },
        findDefaultInlineStreamEnd: function findDefaultInlineStreamEnd(stream) {
          var E = 0x45,
              I = 0x49,
              SPACE = 0x20,
              LF = 0xA,
              CR = 0xD;
          var n = 10,
              NUL = 0x0;
          var startPos = stream.pos,
              state = 0,
              ch = void 0,
              maybeEIPos = void 0;
          while ((ch = stream.getByte()) !== -1) {
            if (state === 0) {
              state = ch === E ? 1 : 0;
            } else if (state === 1) {
              state = ch === I ? 2 : 0;
            } else {
              (0, _util.assert)(state === 2);
              if (ch === SPACE || ch === LF || ch === CR) {
                maybeEIPos = stream.pos;
                var followingBytes = stream.peekBytes(n);
                for (var i = 0, ii = followingBytes.length; i < ii; i++) {
                  ch = followingBytes[i];
                  if (ch === NUL && followingBytes[i + 1] !== NUL) {
                    continue;
                  }
                  if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
                    state = 0;
                    break;
                  }
                }
                if (state === 2) {
                  break;
                }
              } else {
                state = 0;
              }
            }
          }
          if (ch === -1) {
            (0, _util.warn)('findDefaultInlineStreamEnd: ' + 'Reached the end of the stream without finding a valid EI marker');
            if (maybeEIPos) {
              (0, _util.warn)('... trying to recover by using the last "EI" occurrence.');
              stream.skip(-(stream.pos - maybeEIPos));
            }
          }
          return stream.pos - 4 - startPos;
        },
    
        findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
          var startPos = stream.pos,
              foundEOI = false,
              b,
              markerLength,
              length;
          while ((b = stream.getByte()) !== -1) {
            if (b !== 0xFF) {
              continue;
            }
            switch (stream.getByte()) {
              case 0x00:
                break;
              case 0xFF:
                stream.skip(-1);
                break;
              case 0xD9:
                foundEOI = true;
                break;
              case 0xC0:
              case 0xC1:
              case 0xC2:
              case 0xC3:
              case 0xC5:
              case 0xC6:
              case 0xC7:
              case 0xC9:
              case 0xCA:
              case 0xCB:
              case 0xCD:
              case 0xCE:
              case 0xCF:
              case 0xC4:
              case 0xCC:
              case 0xDA:
              case 0xDB:
              case 0xDC:
              case 0xDD:
              case 0xDE:
              case 0xDF:
              case 0xE0:
              case 0xE1:
              case 0xE2:
              case 0xE3:
              case 0xE4:
              case 0xE5:
              case 0xE6:
              case 0xE7:
              case 0xE8:
              case 0xE9:
              case 0xEA:
              case 0xEB:
              case 0xEC:
              case 0xED:
              case 0xEE:
              case 0xEF:
              case 0xFE:
                markerLength = stream.getUint16();
                if (markerLength > 2) {
                  stream.skip(markerLength - 2);
                } else {
                  stream.skip(-2);
                }
                break;
            }
            if (foundEOI) {
              break;
            }
          }
          length = stream.pos - startPos;
          if (b === -1) {
            (0, _util.warn)('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
            stream.skip(-length);
            return this.findDefaultInlineStreamEnd(stream);
          }
          this.inlineStreamSkipEI(stream);
          return length;
        },
        findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
          var TILDE = 0x7E,
              GT = 0x3E;
          var startPos = stream.pos,
              ch,
              length;
          while ((ch = stream.getByte()) !== -1) {
            if (ch === TILDE && stream.peekByte() === GT) {
              stream.skip();
              break;
            }
          }
          length = stream.pos - startPos;
          if (ch === -1) {
            (0, _util.warn)('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
            stream.skip(-length);
            return this.findDefaultInlineStreamEnd(stream);
          }
          this.inlineStreamSkipEI(stream);
          return length;
        },
        findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
          var GT = 0x3E;
          var startPos = stream.pos,
              ch,
              length;
          while ((ch = stream.getByte()) !== -1) {
            if (ch === GT) {
              break;
            }
          }
          length = stream.pos - startPos;
          if (ch === -1) {
            (0, _util.warn)('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
            stream.skip(-length);
            return this.findDefaultInlineStreamEnd(stream);
          }
          this.inlineStreamSkipEI(stream);
          return length;
        },
        inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
          var E = 0x45,
              I = 0x49;
          var state = 0,
              ch;
          while ((ch = stream.getByte()) !== -1) {
            if (state === 0) {
              state = ch === E ? 1 : 0;
            } else if (state === 1) {
              state = ch === I ? 2 : 0;
            } else if (state === 2) {
              break;
            }
          }
        },
        makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
          var lexer = this.lexer;
          var stream = lexer.stream;
          var dict = new _primitives.Dict(this.xref),
              dictLength = void 0;
          while (!(0, _primitives.isCmd)(this.buf1, 'ID') && !(0, _primitives.isEOF)(this.buf1)) {
            if (!(0, _primitives.isName)(this.buf1)) {
              throw new _util.FormatError('Dictionary key must be a name object');
            }
            var key = this.buf1.name;
            this.shift();
            if ((0, _primitives.isEOF)(this.buf1)) {
              break;
            }
            dict.set(key, this.getObj(cipherTransform));
          }
          if (lexer.beginInlineImagePos !== -1) {
            dictLength = stream.pos - lexer.beginInlineImagePos;
          }
          var filter = dict.get('Filter', 'F'),
              filterName;
          if ((0, _primitives.isName)(filter)) {
            filterName = filter.name;
          } else if (Array.isArray(filter)) {
            var filterZero = this.xref.fetchIfRef(filter[0]);
            if ((0, _primitives.isName)(filterZero)) {
              filterName = filterZero.name;
            }
          }
          var startPos = stream.pos,
              length = void 0;
          if (filterName === 'DCTDecode' || filterName === 'DCT') {
            length = this.findDCTDecodeInlineStreamEnd(stream);
          } else if (filterName === 'ASCII85Decode' || filterName === 'A85') {
            length = this.findASCII85DecodeInlineStreamEnd(stream);
          } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
            length = this.findASCIIHexDecodeInlineStreamEnd(stream);
          } else {
            length = this.findDefaultInlineStreamEnd(stream);
          }
          var imageStream = stream.makeSubStream(startPos, length, dict);
          var cacheKey = void 0;
          if (length < MAX_LENGTH_TO_CACHE && dictLength < MAX_ADLER32_LENGTH) {
            var imageBytes = imageStream.getBytes();
            imageStream.reset();
            var initialStreamPos = stream.pos;
            stream.pos = lexer.beginInlineImagePos;
            var dictBytes = stream.getBytes(dictLength);
            stream.pos = initialStreamPos;
            cacheKey = computeAdler32(imageBytes) + '_' + computeAdler32(dictBytes);
            var cacheEntry = this.imageCache[cacheKey];
            if (cacheEntry !== undefined) {
              this.buf2 = _primitives.Cmd.get('EI');
              this.shift();
              cacheEntry.reset();
              return cacheEntry;
            }
          }
          if (cipherTransform) {
            imageStream = cipherTransform.createStream(imageStream, length);
          }
          imageStream = this.filter(imageStream, dict, length);
          imageStream.dict = dict;
          if (cacheKey !== undefined) {
            imageStream.cacheKey = 'inline_' + length + '_' + cacheKey;
            this.imageCache[cacheKey] = imageStream;
          }
          this.buf2 = _primitives.Cmd.get('EI');
          this.shift();
          return imageStream;
        },
        _findStreamLength: function _findStreamLength(startPos, signature) {
          var stream = this.lexer.stream;
    
          stream.pos = startPos;
          var SCAN_BLOCK_LENGTH = 2048;
          var signatureLength = signature.length;
          while (stream.pos < stream.end) {
            var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
            var scanLength = scanBytes.length - signatureLength;
            if (scanLength <= 0) {
              break;
            }
            var pos = 0;
            while (pos < scanLength) {
              var j = 0;
              while (j < signatureLength && scanBytes[pos + j] === signature[j]) {
                j++;
              }
              if (j >= signatureLength) {
                stream.pos += pos;
                return stream.pos - startPos;
              }
              pos++;
            }
            stream.pos += scanLength;
          }
          return -1;
        },
    
        makeStream: function Parser_makeStream(dict, cipherTransform) {
          var lexer = this.lexer;
          var stream = lexer.stream;
          lexer.skipToNextLine();
          var startPos = stream.pos - 1;
          var length = dict.get('Length');
          if (!Number.isInteger(length)) {
            (0, _util.info)('Bad ' + length + ' attribute in stream');
            length = 0;
          }
          stream.pos = startPos + length;
          lexer.nextChar();
          if (this.tryShift() && (0, _primitives.isCmd)(this.buf2, 'endstream')) {
            this.shift();
          } else {
            var ENDSTREAM_SIGNATURE = new Uint8Array([0x65, 0x6E, 0x64, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6D]);
            var actualLength = this._findStreamLength(startPos, ENDSTREAM_SIGNATURE);
            if (actualLength < 0) {
              var MAX_TRUNCATION = 1;
              for (var i = 1; i <= MAX_TRUNCATION; i++) {
                var end = ENDSTREAM_SIGNATURE.length - i;
                var TRUNCATED_SIGNATURE = ENDSTREAM_SIGNATURE.slice(0, end);
                var maybeLength = this._findStreamLength(startPos, TRUNCATED_SIGNATURE);
                if (maybeLength >= 0) {
                  var lastByte = stream.peekBytes(end + 1)[end];
                  if (!(0, _util.isSpace)(lastByte)) {
                    break;
                  }
                  (0, _util.info)('Found "' + (0, _util.bytesToString)(TRUNCATED_SIGNATURE) + '" when ' + 'searching for endstream command.');
                  actualLength = maybeLength;
                  break;
                }
              }
              if (actualLength < 0) {
                throw new _util.FormatError('Missing endstream command.');
              }
            }
            length = actualLength;
            lexer.nextChar();
            this.shift();
            this.shift();
          }
          this.shift();
          stream = stream.makeSubStream(startPos, length, dict);
          if (cipherTransform) {
            stream = cipherTransform.createStream(stream, length);
          }
          stream = this.filter(stream, dict, length);
          stream.dict = dict;
          return stream;
        },
        filter: function Parser_filter(stream, dict, length) {
          var filter = dict.get('Filter', 'F');
          var params = dict.get('DecodeParms', 'DP');
          if ((0, _primitives.isName)(filter)) {
            if (Array.isArray(params)) {
              (0, _util.warn)('/DecodeParms should not contain an Array, ' + 'when /Filter contains a Name.');
            }
            return this.makeFilter(stream, filter.name, length, params);
          }
          var maybeLength = length;
          if (Array.isArray(filter)) {
            var filterArray = filter;
            var paramsArray = params;
            for (var i = 0, ii = filterArray.length; i < ii; ++i) {
              filter = this.xref.fetchIfRef(filterArray[i]);
              if (!(0, _primitives.isName)(filter)) {
                throw new _util.FormatError('Bad filter name: ' + filter);
              }
              params = null;
              if (Array.isArray(paramsArray) && i in paramsArray) {
                params = this.xref.fetchIfRef(paramsArray[i]);
              }
              stream = this.makeFilter(stream, filter.name, maybeLength, params);
              maybeLength = null;
            }
          }
          return stream;
        },
        makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
          if (maybeLength === 0) {
            (0, _util.warn)('Empty "' + name + '" stream.');
            return new _stream.NullStream();
          }
          try {
            var xrefStreamStats = this.xref.stats.streamTypes;
            if (name === 'FlateDecode' || name === 'Fl') {
              xrefStreamStats[_util.StreamType.FLATE] = true;
              if (params) {
                return new _stream.PredictorStream(new _stream.FlateStream(stream, maybeLength), maybeLength, params);
              }
              return new _stream.FlateStream(stream, maybeLength);
            }
            if (name === 'LZWDecode' || name === 'LZW') {
              xrefStreamStats[_util.StreamType.LZW] = true;
              var earlyChange = 1;
              if (params) {
                if (params.has('EarlyChange')) {
                  earlyChange = params.get('EarlyChange');
                }
                return new _stream.PredictorStream(new _stream.LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
              }
              return new _stream.LZWStream(stream, maybeLength, earlyChange);
            }
            if (name === 'DCTDecode' || name === 'DCT') {
              xrefStreamStats[_util.StreamType.DCT] = true;
              return new _jpeg_stream.JpegStream(stream, maybeLength, stream.dict, params);
            }
            if (name === 'JPXDecode' || name === 'JPX') {
              xrefStreamStats[_util.StreamType.JPX] = true;
              return new _jpx_stream.JpxStream(stream, maybeLength, stream.dict, params);
            }
            if (name === 'ASCII85Decode' || name === 'A85') {
              xrefStreamStats[_util.StreamType.A85] = true;
              return new _stream.Ascii85Stream(stream, maybeLength);
            }
            if (name === 'ASCIIHexDecode' || name === 'AHx') {
              xrefStreamStats[_util.StreamType.AHX] = true;
              return new _stream.AsciiHexStream(stream, maybeLength);
            }
            if (name === 'CCITTFaxDecode' || name === 'CCF') {
              xrefStreamStats[_util.StreamType.CCF] = true;
              return new _ccitt_stream.CCITTFaxStream(stream, maybeLength, params);
            }
            if (name === 'RunLengthDecode' || name === 'RL') {
              xrefStreamStats[_util.StreamType.RL] = true;
              return new _stream.RunLengthStream(stream, maybeLength);
            }
            if (name === 'JBIG2Decode') {
              xrefStreamStats[_util.StreamType.JBIG] = true;
              return new _jbig2_stream.Jbig2Stream(stream, maybeLength, stream.dict, params);
            }
            (0, _util.warn)('filter "' + name + '" not supported yet');
            return stream;
          } catch (ex) {
            if (ex instanceof _util.MissingDataException) {
              throw ex;
            }
            (0, _util.warn)('Invalid stream: \"' + ex + '\"');
            return new _stream.NullStream();
          }
        }
      };
      return Parser;
    }();
    var Lexer = function LexerClosure() {
      function Lexer(stream, knownCommands) {
        this.stream = stream;
        this.nextChar();
        this.strBuf = [];
        this.knownCommands = knownCommands;
        this.beginInlineImagePos = -1;
      }
      var specialChars = [1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 2, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
      function toHexDigit(ch) {
        if (ch >= 0x30 && ch <= 0x39) {
          return ch & 0x0F;
        }
        if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
          return (ch & 0x0F) + 9;
        }
        return -1;
      }
      Lexer.prototype = {
        nextChar: function Lexer_nextChar() {
          return this.currentChar = this.stream.getByte();
        },
        peekChar: function Lexer_peekChar() {
          return this.stream.peekByte();
        },
        getNumber: function Lexer_getNumber() {
          var ch = this.currentChar;
          var eNotation = false;
          var divideBy = 0;
          var sign = 0;
          if (ch === 0x2D) {
            sign = -1;
            ch = this.nextChar();
            if (ch === 0x2D) {
              ch = this.nextChar();
            }
          } else if (ch === 0x2B) {
            sign = 1;
            ch = this.nextChar();
          }
          if (ch === 0x0A || ch === 0x0D) {
            do {
              ch = this.nextChar();
            } while (ch === 0x0A || ch === 0x0D);
          }
          if (ch === 0x2E) {
            divideBy = 10;
            ch = this.nextChar();
          }
          if (ch < 0x30 || ch > 0x39) {
            if (divideBy === 10 && sign === 0 && ((0, _util.isSpace)(ch) || ch === -1)) {
              (0, _util.warn)('Lexer.getNumber - treating a single decimal point as zero.');
              return 0;
            }
            throw new _util.FormatError('Invalid number: ' + String.fromCharCode(ch) + ' (charCode ' + ch + ')');
          }
          sign = sign || 1;
          var baseValue = ch - 0x30;
          var powerValue = 0;
          var powerValueSign = 1;
          while ((ch = this.nextChar()) >= 0) {
            if (0x30 <= ch && ch <= 0x39) {
              var currentDigit = ch - 0x30;
              if (eNotation) {
                powerValue = powerValue * 10 + currentDigit;
              } else {
                if (divideBy !== 0) {
                  divideBy *= 10;
                }
                baseValue = baseValue * 10 + currentDigit;
              }
            } else if (ch === 0x2E) {
              if (divideBy === 0) {
                divideBy = 1;
              } else {
                break;
              }
            } else if (ch === 0x2D) {
              (0, _util.warn)('Badly formatted number');
            } else if (ch === 0x45 || ch === 0x65) {
              ch = this.peekChar();
              if (ch === 0x2B || ch === 0x2D) {
                powerValueSign = ch === 0x2D ? -1 : 1;
                this.nextChar();
              } else if (ch < 0x30 || ch > 0x39) {
                break;
              }
              eNotation = true;
            } else {
              break;
            }
          }
          if (divideBy !== 0) {
            baseValue /= divideBy;
          }
          if (eNotation) {
            baseValue *= Math.pow(10, powerValueSign * powerValue);
          }
          return sign * baseValue;
        },
        getString: function Lexer_getString() {
          var numParen = 1;
          var done = false;
          var strBuf = this.strBuf;
          strBuf.length = 0;
          var ch = this.nextChar();
          while (true) {
            var charBuffered = false;
            switch (ch | 0) {
              case -1:
                (0, _util.warn)('Unterminated string');
                done = true;
                break;
              case 0x28:
                ++numParen;
                strBuf.push('(');
                break;
              case 0x29:
                if (--numParen === 0) {
                  this.nextChar();
                  done = true;
                } else {
                  strBuf.push(')');
                }
                break;
              case 0x5C:
                ch = this.nextChar();
                switch (ch) {
                  case -1:
                    (0, _util.warn)('Unterminated string');
                    done = true;
                    break;
                  case 0x6E:
                    strBuf.push('\n');
                    break;
                  case 0x72:
                    strBuf.push('\r');
                    break;
                  case 0x74:
                    strBuf.push('\t');
                    break;
                  case 0x62:
                    strBuf.push('\b');
                    break;
                  case 0x66:
                    strBuf.push('\f');
                    break;
                  case 0x5C:
                  case 0x28:
                  case 0x29:
                    strBuf.push(String.fromCharCode(ch));
                    break;
                  case 0x30:
                  case 0x31:
                  case 0x32:
                  case 0x33:
                  case 0x34:
                  case 0x35:
                  case 0x36:
                  case 0x37:
                    var x = ch & 0x0F;
                    ch = this.nextChar();
                    charBuffered = true;
                    if (ch >= 0x30 && ch <= 0x37) {
                      x = (x << 3) + (ch & 0x0F);
                      ch = this.nextChar();
                      if (ch >= 0x30 && ch <= 0x37) {
                        charBuffered = false;
                        x = (x << 3) + (ch & 0x0F);
                      }
                    }
                    strBuf.push(String.fromCharCode(x));
                    break;
                  case 0x0D:
                    if (this.peekChar() === 0x0A) {
                      this.nextChar();
                    }
                    break;
                  case 0x0A: