How to use __w_pdfjs_require__ method in wpt

Best JavaScript code snippet using wpt

pdf_viewer.js

Source:pdf_viewer.js Github

copy

Full Screen

...26/******/ // The module cache27/******/ var installedModules = {};28/******/29/******/ // The require function30/******/ function __w_pdfjs_require__(moduleId) {31/******/32/******/ // Check if module is in cache33/******/ if(installedModules[moduleId]) {34/******/ return installedModules[moduleId].exports;35/******/ }36/******/ // Create a new module (and put it into the cache)37/******/ var module = installedModules[moduleId] = {38/******/ i: moduleId,39/******/ l: false,40/******/ exports: {}41/******/ };42/******/43/******/ // Execute the module function44/******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);45/******/46/******/ // Flag the module as loaded47/******/ module.l = true;48/******/49/******/ // Return the exports of the module50/******/ return module.exports;51/******/ }52/******/53/******/54/******/ // expose the modules object (__webpack_modules__)55/******/ __w_pdfjs_require__.m = modules;56/******/57/******/ // expose the module cache58/******/ __w_pdfjs_require__.c = installedModules;59/******/60/******/ // define getter function for harmony exports61/******/ __w_pdfjs_require__.d = function(exports, name, getter) {62/******/ if(!__w_pdfjs_require__.o(exports, name)) {63/******/ Object.defineProperty(exports, name, {64/******/ configurable: false,65/******/ enumerable: true,66/******/ get: getter67/******/ });68/******/ }69/******/ };70/******/71/******/ // getDefaultExport function for compatibility with non-harmony modules72/******/ __w_pdfjs_require__.n = function(module) {73/******/ var getter = module && module.__esModule ?74/******/ function getDefault() { return module['default']; } :75/******/ function getModuleExports() { return module; };76/******/ __w_pdfjs_require__.d(getter, 'a', getter);77/******/ return getter;78/******/ };79/******/80/******/ // Object.prototype.hasOwnProperty.call81/******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };82/******/83/******/ // __webpack_public_path__84/******/ __w_pdfjs_require__.p = "";85/******/86/******/ // Load entry module and return exports87/******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 9);88/******/ })89/************************************************************************/90/******/ ([91/* 0 */92/***/ (function(module, exports, __w_pdfjs_require__) {93"use strict";94var pdfjsLib;95if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {96 pdfjsLib = window['pdfjs-dist/build/pdf'];97} else {98 pdfjsLib = require('../build/pdf.js');99}100module.exports = pdfjsLib;101/***/ }),102/* 1 */103/***/ (function(module, exports, __w_pdfjs_require__) {104"use strict";105Object.defineProperty(exports, "__esModule", {106 value: true107});108exports.waitOnEventOrTimeout = exports.WaitOnType = exports.localized = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.roundToDivide = exports.getVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.mozL10n = exports.RendererType = exports.PresentationModeState = exports.cloneObj = exports.isValidRotation = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = undefined;109var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();110var _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; };111var _pdfjsLib = __w_pdfjs_require__(0);112function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }113var CSS_UNITS = 96.0 / 72.0;114var DEFAULT_SCALE_VALUE = 'auto';115var DEFAULT_SCALE = 1.0;116var MIN_SCALE = 0.25;117var MAX_SCALE = 10.0;118var UNKNOWN_SCALE = 0;119var MAX_AUTO_SCALE = 1.25;120var SCROLLBAR_PADDING = 40;121var VERTICAL_PADDING = 5;122var PresentationModeState = {123 UNKNOWN: 0,124 NORMAL: 1,125 CHANGING: 2,126 FULLSCREEN: 3127};128var RendererType = {129 CANVAS: 'canvas',130 SVG: 'svg'131};132function formatL10nValue(text, args) {133 if (!args) {134 return text;135 }136 return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {137 return name in args ? args[name] : '{{' + name + '}}';138 });139}140var NullL10n = {141 get: function get(property, args, fallback) {142 return Promise.resolve(formatL10nValue(fallback, args));143 },144 translate: function translate(element) {145 return Promise.resolve();146 }147};148_pdfjsLib.PDFJS.disableFullscreen = _pdfjsLib.PDFJS.disableFullscreen === undefined ? false : _pdfjsLib.PDFJS.disableFullscreen;149_pdfjsLib.PDFJS.useOnlyCssZoom = _pdfjsLib.PDFJS.useOnlyCssZoom === undefined ? false : _pdfjsLib.PDFJS.useOnlyCssZoom;150_pdfjsLib.PDFJS.maxCanvasPixels = _pdfjsLib.PDFJS.maxCanvasPixels === undefined ? 16777216 : _pdfjsLib.PDFJS.maxCanvasPixels;151_pdfjsLib.PDFJS.disableHistory = _pdfjsLib.PDFJS.disableHistory === undefined ? false : _pdfjsLib.PDFJS.disableHistory;152_pdfjsLib.PDFJS.disableTextLayer = _pdfjsLib.PDFJS.disableTextLayer === undefined ? false : _pdfjsLib.PDFJS.disableTextLayer;153_pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom = _pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom === undefined ? false : _pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom;154{155 _pdfjsLib.PDFJS.locale = _pdfjsLib.PDFJS.locale === undefined && typeof navigator !== 'undefined' ? navigator.language : _pdfjsLib.PDFJS.locale;156}157function getOutputScale(ctx) {158 var devicePixelRatio = window.devicePixelRatio || 1;159 var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;160 var pixelRatio = devicePixelRatio / backingStoreRatio;161 return {162 sx: pixelRatio,163 sy: pixelRatio,164 scaled: pixelRatio !== 1165 };166}167function scrollIntoView(element, spot) {168 var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;169 var parent = element.offsetParent;170 if (!parent) {171 console.error('offsetParent is not set -- cannot scroll');172 return;173 }174 var offsetY = element.offsetTop + element.clientTop;175 var offsetX = element.offsetLeft + element.clientLeft;176 while (parent.clientHeight === parent.scrollHeight || skipOverflowHiddenElements && getComputedStyle(parent).overflow === 'hidden') {177 if (parent.dataset._scaleY) {178 offsetY /= parent.dataset._scaleY;179 offsetX /= parent.dataset._scaleX;180 }181 offsetY += parent.offsetTop;182 offsetX += parent.offsetLeft;183 parent = parent.offsetParent;184 if (!parent) {185 return;186 }187 }188 if (spot) {189 if (spot.top !== undefined) {190 offsetY += spot.top;191 }192 if (spot.left !== undefined) {193 offsetX += spot.left;194 parent.scrollLeft = offsetX;195 }196 }197 parent.scrollTop = offsetY;198}199function watchScroll(viewAreaElement, callback) {200 var debounceScroll = function debounceScroll(evt) {201 if (rAF) {202 return;203 }204 rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {205 rAF = null;206 var currentY = viewAreaElement.scrollTop;207 var lastY = state.lastY;208 if (currentY !== lastY) {209 state.down = currentY > lastY;210 }211 state.lastY = currentY;212 callback(state);213 });214 };215 var state = {216 down: true,217 lastY: viewAreaElement.scrollTop,218 _eventHandler: debounceScroll219 };220 var rAF = null;221 viewAreaElement.addEventListener('scroll', debounceScroll, true);222 return state;223}224function parseQueryString(query) {225 var parts = query.split('&');226 var params = Object.create(null);227 for (var i = 0, ii = parts.length; i < ii; ++i) {228 var param = parts[i].split('=');229 var key = param[0].toLowerCase();230 var value = param.length > 1 ? param[1] : null;231 params[decodeURIComponent(key)] = decodeURIComponent(value);232 }233 return params;234}235function binarySearchFirstItem(items, condition) {236 var minIndex = 0;237 var maxIndex = items.length - 1;238 if (items.length === 0 || !condition(items[maxIndex])) {239 return items.length;240 }241 if (condition(items[minIndex])) {242 return minIndex;243 }244 while (minIndex < maxIndex) {245 var currentIndex = minIndex + maxIndex >> 1;246 var currentItem = items[currentIndex];247 if (condition(currentItem)) {248 maxIndex = currentIndex;249 } else {250 minIndex = currentIndex + 1;251 }252 }253 return minIndex;254}255function approximateFraction(x) {256 if (Math.floor(x) === x) {257 return [x, 1];258 }259 var xinv = 1 / x;260 var limit = 8;261 if (xinv > limit) {262 return [1, limit];263 } else if (Math.floor(xinv) === xinv) {264 return [1, xinv];265 }266 var x_ = x > 1 ? xinv : x;267 var a = 0,268 b = 1,269 c = 1,270 d = 1;271 while (true) {272 var p = a + c,273 q = b + d;274 if (q > limit) {275 break;276 }277 if (x_ <= p / q) {278 c = p;279 d = q;280 } else {281 a = p;282 b = q;283 }284 }285 var result = void 0;286 if (x_ - a / b < c / d - x_) {287 result = x_ === x ? [a, b] : [b, a];288 } else {289 result = x_ === x ? [c, d] : [d, c];290 }291 return result;292}293function roundToDivide(x, div) {294 var r = x % div;295 return r === 0 ? x : Math.round(x - r + div);296}297function getVisibleElements(scrollEl, views) {298 var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;299 var top = scrollEl.scrollTop,300 bottom = top + scrollEl.clientHeight;301 var left = scrollEl.scrollLeft,302 right = left + scrollEl.clientWidth;303 function isElementBottomBelowViewTop(view) {304 var element = view.div;305 var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;306 return elementBottom > top;307 }308 var visible = [],309 view = void 0,310 element = void 0;311 var currentHeight = void 0,312 viewHeight = void 0,313 hiddenHeight = void 0,314 percentHeight = void 0;315 var currentWidth = void 0,316 viewWidth = void 0;317 var firstVisibleElementInd = views.length === 0 ? 0 : binarySearchFirstItem(views, isElementBottomBelowViewTop);318 for (var i = firstVisibleElementInd, ii = views.length; i < ii; i++) {319 view = views[i];320 element = view.div;321 currentHeight = element.offsetTop + element.clientTop;322 viewHeight = element.clientHeight;323 if (currentHeight > bottom) {324 break;325 }326 currentWidth = element.offsetLeft + element.clientLeft;327 viewWidth = element.clientWidth;328 if (currentWidth + viewWidth < left || currentWidth > right) {329 continue;330 }331 hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, currentHeight + viewHeight - bottom);332 percentHeight = (viewHeight - hiddenHeight) * 100 / viewHeight | 0;333 visible.push({334 id: view.id,335 x: currentWidth,336 y: currentHeight,337 view: view,338 percent: percentHeight339 });340 }341 var first = visible[0];342 var last = visible[visible.length - 1];343 if (sortByVisibility) {344 visible.sort(function (a, b) {345 var pc = a.percent - b.percent;346 if (Math.abs(pc) > 0.001) {347 return -pc;348 }349 return a.id - b.id;350 });351 }352 return {353 first: first,354 last: last,355 views: visible356 };357}358function noContextMenuHandler(evt) {359 evt.preventDefault();360}361function isDataSchema(url) {362 var i = 0,363 ii = url.length;364 while (i < ii && url[i].trim() === '') {365 i++;366 }367 return url.substr(i, 5).toLowerCase() === 'data:';368}369function getPDFFileNameFromURL(url) {370 var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';371 if (isDataSchema(url)) {372 console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');373 return defaultFilename;374 }375 var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;376 var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;377 var splitURI = reURI.exec(url);378 var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);379 if (suggestedFilename) {380 suggestedFilename = suggestedFilename[0];381 if (suggestedFilename.indexOf('%') !== -1) {382 try {383 suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];384 } catch (ex) {}385 }386 }387 return suggestedFilename || defaultFilename;388}389function normalizeWheelEventDelta(evt) {390 var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);391 var angle = Math.atan2(evt.deltaY, evt.deltaX);392 if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {393 delta = -delta;394 }395 var MOUSE_DOM_DELTA_PIXEL_MODE = 0;396 var MOUSE_DOM_DELTA_LINE_MODE = 1;397 var MOUSE_PIXELS_PER_LINE = 30;398 var MOUSE_LINES_PER_PAGE = 30;399 if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {400 delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;401 } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {402 delta /= MOUSE_LINES_PER_PAGE;403 }404 return delta;405}406function isValidRotation(angle) {407 return Number.isInteger(angle) && angle % 90 === 0;408}409function cloneObj(obj) {410 var result = Object.create(null);411 for (var i in obj) {412 if (Object.prototype.hasOwnProperty.call(obj, i)) {413 result[i] = obj[i];414 }415 }416 return result;417}418var WaitOnType = {419 EVENT: 'event',420 TIMEOUT: 'timeout'421};422function waitOnEventOrTimeout(_ref) {423 var target = _ref.target,424 name = _ref.name,425 _ref$delay = _ref.delay,426 delay = _ref$delay === undefined ? 0 : _ref$delay;427 if ((typeof target === 'undefined' ? 'undefined' : _typeof(target)) !== 'object' || !(name && typeof name === 'string') || !(Number.isInteger(delay) && delay >= 0)) {428 return Promise.reject(new Error('waitOnEventOrTimeout - invalid paramaters.'));429 }430 var capability = (0, _pdfjsLib.createPromiseCapability)();431 function handler(type) {432 if (target instanceof EventBus) {433 target.off(name, eventHandler);434 } else {435 target.removeEventListener(name, eventHandler);436 }437 if (timeout) {438 clearTimeout(timeout);439 }440 capability.resolve(type);441 }442 var eventHandler = handler.bind(null, WaitOnType.EVENT);443 if (target instanceof EventBus) {444 target.on(name, eventHandler);445 } else {446 target.addEventListener(name, eventHandler);447 }448 var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);449 var timeout = setTimeout(timeoutHandler, delay);450 return capability.promise;451}452var animationStarted = new Promise(function (resolve) {453 window.requestAnimationFrame(resolve);454});455var mozL10n = void 0;456var localized = Promise.resolve();457var EventBus = function () {458 function EventBus() {459 _classCallCheck(this, EventBus);460 this._listeners = Object.create(null);461 }462 _createClass(EventBus, [{463 key: 'on',464 value: function on(eventName, listener) {465 var eventListeners = this._listeners[eventName];466 if (!eventListeners) {467 eventListeners = [];468 this._listeners[eventName] = eventListeners;469 }470 eventListeners.push(listener);471 }472 }, {473 key: 'off',474 value: function off(eventName, listener) {475 var eventListeners = this._listeners[eventName];476 var i = void 0;477 if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {478 return;479 }480 eventListeners.splice(i, 1);481 }482 }, {483 key: 'dispatch',484 value: function dispatch(eventName) {485 var eventListeners = this._listeners[eventName];486 if (!eventListeners || eventListeners.length === 0) {487 return;488 }489 var args = Array.prototype.slice.call(arguments, 1);490 eventListeners.slice(0).forEach(function (listener) {491 listener.apply(null, args);492 });493 }494 }]);495 return EventBus;496}();497function clamp(v, min, max) {498 return Math.min(Math.max(v, min), max);499}500var ProgressBar = function () {501 function ProgressBar(id) {502 var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},503 height = _ref2.height,504 width = _ref2.width,505 units = _ref2.units;506 _classCallCheck(this, ProgressBar);507 this.visible = true;508 this.div = document.querySelector(id + ' .progress');509 this.bar = this.div.parentNode;510 this.height = height || 100;511 this.width = width || 100;512 this.units = units || '%';513 this.div.style.height = this.height + this.units;514 this.percent = 0;515 }516 _createClass(ProgressBar, [{517 key: '_updateBar',518 value: function _updateBar() {519 if (this._indeterminate) {520 this.div.classList.add('indeterminate');521 this.div.style.width = this.width + this.units;522 return;523 }524 this.div.classList.remove('indeterminate');525 var progressSize = this.width * this._percent / 100;526 this.div.style.width = progressSize + this.units;527 }528 }, {529 key: 'setWidth',530 value: function setWidth(viewer) {531 if (!viewer) {532 return;533 }534 var container = viewer.parentNode;535 var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;536 if (scrollbarWidth > 0) {537 this.bar.setAttribute('style', 'width: calc(100% - ' + scrollbarWidth + 'px);');538 }539 }540 }, {541 key: 'hide',542 value: function hide() {543 if (!this.visible) {544 return;545 }546 this.visible = false;547 this.bar.classList.add('hidden');548 document.body.classList.remove('loadingInProgress');549 }550 }, {551 key: 'show',552 value: function show() {553 if (this.visible) {554 return;555 }556 this.visible = true;557 document.body.classList.add('loadingInProgress');558 this.bar.classList.remove('hidden');559 }560 }, {561 key: 'percent',562 get: function get() {563 return this._percent;564 },565 set: function set(val) {566 this._indeterminate = isNaN(val);567 this._percent = clamp(val, 0, 100);568 this._updateBar();569 }570 }]);571 return ProgressBar;572}();573exports.CSS_UNITS = CSS_UNITS;574exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;575exports.DEFAULT_SCALE = DEFAULT_SCALE;576exports.MIN_SCALE = MIN_SCALE;577exports.MAX_SCALE = MAX_SCALE;578exports.UNKNOWN_SCALE = UNKNOWN_SCALE;579exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;580exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;581exports.VERTICAL_PADDING = VERTICAL_PADDING;582exports.isValidRotation = isValidRotation;583exports.cloneObj = cloneObj;584exports.PresentationModeState = PresentationModeState;585exports.RendererType = RendererType;586exports.mozL10n = mozL10n;587exports.NullL10n = NullL10n;588exports.EventBus = EventBus;589exports.ProgressBar = ProgressBar;590exports.getPDFFileNameFromURL = getPDFFileNameFromURL;591exports.noContextMenuHandler = noContextMenuHandler;592exports.parseQueryString = parseQueryString;593exports.getVisibleElements = getVisibleElements;594exports.roundToDivide = roundToDivide;595exports.approximateFraction = approximateFraction;596exports.getOutputScale = getOutputScale;597exports.scrollIntoView = scrollIntoView;598exports.watchScroll = watchScroll;599exports.binarySearchFirstItem = binarySearchFirstItem;600exports.normalizeWheelEventDelta = normalizeWheelEventDelta;601exports.animationStarted = animationStarted;602exports.localized = localized;603exports.WaitOnType = WaitOnType;604exports.waitOnEventOrTimeout = waitOnEventOrTimeout;605/***/ }),606/* 2 */607/***/ (function(module, exports, __w_pdfjs_require__) {608"use strict";609Object.defineProperty(exports, "__esModule", {610 value: true611});612exports.getGlobalEventBus = exports.attachDOMEventsToEventBus = undefined;613var _ui_utils = __w_pdfjs_require__(1);614function attachDOMEventsToEventBus(eventBus) {615 eventBus.on('documentload', function () {616 var event = document.createEvent('CustomEvent');617 event.initCustomEvent('documentload', true, true, {});618 window.dispatchEvent(event);619 });620 eventBus.on('pagerendered', function (evt) {621 var event = document.createEvent('CustomEvent');622 event.initCustomEvent('pagerendered', true, true, {623 pageNumber: evt.pageNumber,624 cssTransform: evt.cssTransform625 });626 evt.source.div.dispatchEvent(event);627 });628 eventBus.on('textlayerrendered', function (evt) {629 var event = document.createEvent('CustomEvent');630 event.initCustomEvent('textlayerrendered', true, true, { pageNumber: evt.pageNumber });631 evt.source.textLayerDiv.dispatchEvent(event);632 });633 eventBus.on('pagechange', function (evt) {634 var event = document.createEvent('UIEvents');635 event.initUIEvent('pagechange', true, true, window, 0);636 event.pageNumber = evt.pageNumber;637 evt.source.container.dispatchEvent(event);638 });639 eventBus.on('pagesinit', function (evt) {640 var event = document.createEvent('CustomEvent');641 event.initCustomEvent('pagesinit', true, true, null);642 evt.source.container.dispatchEvent(event);643 });644 eventBus.on('pagesloaded', function (evt) {645 var event = document.createEvent('CustomEvent');646 event.initCustomEvent('pagesloaded', true, true, { pagesCount: evt.pagesCount });647 evt.source.container.dispatchEvent(event);648 });649 eventBus.on('scalechange', function (evt) {650 var event = document.createEvent('UIEvents');651 event.initUIEvent('scalechange', true, true, window, 0);652 event.scale = evt.scale;653 event.presetValue = evt.presetValue;654 evt.source.container.dispatchEvent(event);655 });656 eventBus.on('updateviewarea', function (evt) {657 var event = document.createEvent('UIEvents');658 event.initUIEvent('updateviewarea', true, true, window, 0);659 event.location = evt.location;660 evt.source.container.dispatchEvent(event);661 });662 eventBus.on('find', function (evt) {663 if (evt.source === window) {664 return;665 }666 var event = document.createEvent('CustomEvent');667 event.initCustomEvent('find' + evt.type, true, true, {668 query: evt.query,669 phraseSearch: evt.phraseSearch,670 caseSensitive: evt.caseSensitive,671 highlightAll: evt.highlightAll,672 findPrevious: evt.findPrevious673 });674 window.dispatchEvent(event);675 });676 eventBus.on('attachmentsloaded', function (evt) {677 var event = document.createEvent('CustomEvent');678 event.initCustomEvent('attachmentsloaded', true, true, { attachmentsCount: evt.attachmentsCount });679 evt.source.container.dispatchEvent(event);680 });681 eventBus.on('sidebarviewchanged', function (evt) {682 var event = document.createEvent('CustomEvent');683 event.initCustomEvent('sidebarviewchanged', true, true, { view: evt.view });684 evt.source.outerContainer.dispatchEvent(event);685 });686 eventBus.on('pagemode', function (evt) {687 var event = document.createEvent('CustomEvent');688 event.initCustomEvent('pagemode', true, true, { mode: evt.mode });689 evt.source.pdfViewer.container.dispatchEvent(event);690 });691 eventBus.on('namedaction', function (evt) {692 var event = document.createEvent('CustomEvent');693 event.initCustomEvent('namedaction', true, true, { action: evt.action });694 evt.source.pdfViewer.container.dispatchEvent(event);695 });696 eventBus.on('presentationmodechanged', function (evt) {697 var event = document.createEvent('CustomEvent');698 event.initCustomEvent('presentationmodechanged', true, true, {699 active: evt.active,700 switchInProgress: evt.switchInProgress701 });702 window.dispatchEvent(event);703 });704 eventBus.on('outlineloaded', function (evt) {705 var event = document.createEvent('CustomEvent');706 event.initCustomEvent('outlineloaded', true, true, { outlineCount: evt.outlineCount });707 evt.source.container.dispatchEvent(event);708 });709}710var globalEventBus = null;711function getGlobalEventBus() {712 if (globalEventBus) {713 return globalEventBus;714 }715 globalEventBus = new _ui_utils.EventBus();716 attachDOMEventsToEventBus(globalEventBus);717 return globalEventBus;718}719exports.attachDOMEventsToEventBus = attachDOMEventsToEventBus;720exports.getGlobalEventBus = getGlobalEventBus;721/***/ }),722/* 3 */723/***/ (function(module, exports, __w_pdfjs_require__) {724"use strict";725Object.defineProperty(exports, "__esModule", {726 value: true727});728exports.SimpleLinkService = exports.PDFLinkService = undefined;729var _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; };730var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();731var _dom_events = __w_pdfjs_require__(2);732var _ui_utils = __w_pdfjs_require__(1);733function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }734var PDFLinkService = function () {735 function PDFLinkService() {736 var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},737 eventBus = _ref.eventBus;738 _classCallCheck(this, PDFLinkService);739 this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();740 this.baseUrl = null;741 this.pdfDocument = null;742 this.pdfViewer = null;743 this.pdfHistory = null;744 this._pagesRefCache = null;745 }746 _createClass(PDFLinkService, [{747 key: 'setDocument',748 value: function setDocument(pdfDocument, baseUrl) {749 this.baseUrl = baseUrl;750 this.pdfDocument = pdfDocument;751 this._pagesRefCache = Object.create(null);752 }753 }, {754 key: 'setViewer',755 value: function setViewer(pdfViewer) {756 this.pdfViewer = pdfViewer;757 }758 }, {759 key: 'setHistory',760 value: function setHistory(pdfHistory) {761 this.pdfHistory = pdfHistory;762 }763 }, {764 key: 'navigateTo',765 value: function navigateTo(dest) {766 var _this = this;767 var goToDestination = function goToDestination(_ref2) {768 var namedDest = _ref2.namedDest,769 explicitDest = _ref2.explicitDest;770 var destRef = explicitDest[0],771 pageNumber = void 0;772 if (destRef instanceof Object) {773 pageNumber = _this._cachedPageNumber(destRef);774 if (pageNumber === null) {775 _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {776 _this.cachePageRef(pageIndex + 1, destRef);777 goToDestination({778 namedDest: namedDest,779 explicitDest: explicitDest780 });781 }).catch(function () {782 console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid page reference, for dest="' + dest + '".'));783 });784 return;785 }786 } else if (Number.isInteger(destRef)) {787 pageNumber = destRef + 1;788 } else {789 console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid destination reference, for dest="' + dest + '".'));790 return;791 }792 if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {793 console.error('PDFLinkService.navigateTo: "' + pageNumber + '" is not ' + ('a valid page number, for dest="' + dest + '".'));794 return;795 }796 if (_this.pdfHistory) {797 _this.pdfHistory.pushCurrentPosition();798 _this.pdfHistory.push({799 namedDest: namedDest,800 explicitDest: explicitDest,801 pageNumber: pageNumber802 });803 }804 _this.pdfViewer.scrollPageIntoView({805 pageNumber: pageNumber,806 destArray: explicitDest807 });808 };809 new Promise(function (resolve, reject) {810 if (typeof dest === 'string') {811 _this.pdfDocument.getDestination(dest).then(function (destArray) {812 resolve({813 namedDest: dest,814 explicitDest: destArray815 });816 });817 return;818 }819 resolve({820 namedDest: '',821 explicitDest: dest822 });823 }).then(function (data) {824 if (!(data.explicitDest instanceof Array)) {825 console.error('PDFLinkService.navigateTo: "' + data.explicitDest + '" is' + (' not a valid destination array, for dest="' + dest + '".'));826 return;827 }828 goToDestination(data);829 });830 }831 }, {832 key: 'getDestinationHash',833 value: function getDestinationHash(dest) {834 if (typeof dest === 'string') {835 return this.getAnchorUrl('#' + escape(dest));836 }837 if (dest instanceof Array) {838 var str = JSON.stringify(dest);839 return this.getAnchorUrl('#' + escape(str));840 }841 return this.getAnchorUrl('');842 }843 }, {844 key: 'getAnchorUrl',845 value: function getAnchorUrl(anchor) {846 return (this.baseUrl || '') + anchor;847 }848 }, {849 key: 'setHash',850 value: function setHash(hash) {851 var pageNumber = void 0,852 dest = void 0;853 if (hash.indexOf('=') >= 0) {854 var params = (0, _ui_utils.parseQueryString)(hash);855 if ('search' in params) {856 this.eventBus.dispatch('findfromurlhash', {857 source: this,858 query: params['search'].replace(/"/g, ''),859 phraseSearch: params['phrase'] === 'true'860 });861 }862 if ('nameddest' in params) {863 this.navigateTo(params.nameddest);864 return;865 }866 if ('page' in params) {867 pageNumber = params.page | 0 || 1;868 }869 if ('zoom' in params) {870 var zoomArgs = params.zoom.split(',');871 var zoomArg = zoomArgs[0];872 var zoomArgNumber = parseFloat(zoomArg);873 if (zoomArg.indexOf('Fit') === -1) {874 dest = [null, { name: 'XYZ' }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];875 } else {876 if (zoomArg === 'Fit' || zoomArg === 'FitB') {877 dest = [null, { name: zoomArg }];878 } else if (zoomArg === 'FitH' || zoomArg === 'FitBH' || zoomArg === 'FitV' || zoomArg === 'FitBV') {879 dest = [null, { name: zoomArg }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];880 } else if (zoomArg === 'FitR') {881 if (zoomArgs.length !== 5) {882 console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');883 } else {884 dest = [null, { name: zoomArg }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];885 }886 } else {887 console.error('PDFLinkService.setHash: "' + zoomArg + '" is not ' + 'a valid zoom value.');888 }889 }890 }891 if (dest) {892 this.pdfViewer.scrollPageIntoView({893 pageNumber: pageNumber || this.page,894 destArray: dest,895 allowNegativeOffset: true896 });897 } else if (pageNumber) {898 this.page = pageNumber;899 }900 if ('pagemode' in params) {901 this.eventBus.dispatch('pagemode', {902 source: this,903 mode: params.pagemode904 });905 }906 } else {907 if (/^\d+$/.test(hash) && hash <= this.pagesCount) {908 console.warn('PDFLinkService_setHash: specifying a page number ' + 'directly after the hash symbol (#) is deprecated, ' + ('please use the "#page=' + hash + '" form instead.'));909 this.page = hash | 0;910 }911 dest = unescape(hash);912 try {913 dest = JSON.parse(dest);914 if (!(dest instanceof Array)) {915 dest = dest.toString();916 }917 } catch (ex) {}918 if (typeof dest === 'string' || isValidExplicitDestination(dest)) {919 this.navigateTo(dest);920 return;921 }922 console.error('PDFLinkService.setHash: "' + unescape(hash) + '" is not ' + 'a valid destination.');923 }924 }925 }, {926 key: 'executeNamedAction',927 value: function executeNamedAction(action) {928 switch (action) {929 case 'GoBack':930 if (this.pdfHistory) {931 this.pdfHistory.back();932 }933 break;934 case 'GoForward':935 if (this.pdfHistory) {936 this.pdfHistory.forward();937 }938 break;939 case 'NextPage':940 if (this.page < this.pagesCount) {941 this.page++;942 }943 break;944 case 'PrevPage':945 if (this.page > 1) {946 this.page--;947 }948 break;949 case 'LastPage':950 this.page = this.pagesCount;951 break;952 case 'FirstPage':953 this.page = 1;954 break;955 default:956 break;957 }958 this.eventBus.dispatch('namedaction', {959 source: this,960 action: action961 });962 }963 }, {964 key: 'onFileAttachmentAnnotation',965 value: function onFileAttachmentAnnotation(_ref3) {966 var id = _ref3.id,967 filename = _ref3.filename,968 content = _ref3.content;969 this.eventBus.dispatch('fileattachmentannotation', {970 source: this,971 id: id,972 filename: filename,973 content: content974 });975 }976 }, {977 key: 'cachePageRef',978 value: function cachePageRef(pageNum, pageRef) {979 var refStr = pageRef.num + ' ' + pageRef.gen + ' R';980 this._pagesRefCache[refStr] = pageNum;981 }982 }, {983 key: '_cachedPageNumber',984 value: function _cachedPageNumber(pageRef) {985 var refStr = pageRef.num + ' ' + pageRef.gen + ' R';986 return this._pagesRefCache && this._pagesRefCache[refStr] || null;987 }988 }, {989 key: 'pagesCount',990 get: function get() {991 return this.pdfDocument ? this.pdfDocument.numPages : 0;992 }993 }, {994 key: 'page',995 get: function get() {996 return this.pdfViewer.currentPageNumber;997 },998 set: function set(value) {999 this.pdfViewer.currentPageNumber = value;1000 }1001 }, {1002 key: 'rotation',1003 get: function get() {1004 return this.pdfViewer.pagesRotation;1005 },1006 set: function set(value) {1007 this.pdfViewer.pagesRotation = value;1008 }1009 }]);1010 return PDFLinkService;1011}();1012function isValidExplicitDestination(dest) {1013 if (!(dest instanceof Array)) {1014 return false;1015 }1016 var destLength = dest.length,1017 allowNull = true;1018 if (destLength < 2) {1019 return false;1020 }1021 var page = dest[0];1022 if (!((typeof page === 'undefined' ? 'undefined' : _typeof(page)) === 'object' && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {1023 return false;1024 }1025 var zoom = dest[1];1026 if (!((typeof zoom === 'undefined' ? 'undefined' : _typeof(zoom)) === 'object' && typeof zoom.name === 'string')) {1027 return false;1028 }1029 switch (zoom.name) {1030 case 'XYZ':1031 if (destLength !== 5) {1032 return false;1033 }1034 break;1035 case 'Fit':1036 case 'FitB':1037 return destLength === 2;1038 case 'FitH':1039 case 'FitBH':1040 case 'FitV':1041 case 'FitBV':1042 if (destLength !== 3) {1043 return false;1044 }1045 break;1046 case 'FitR':1047 if (destLength !== 6) {1048 return false;1049 }1050 allowNull = false;1051 break;1052 default:1053 return false;1054 }1055 for (var i = 2; i < destLength; i++) {1056 var param = dest[i];1057 if (!(typeof param === 'number' || allowNull && param === null)) {1058 return false;1059 }1060 }1061 return true;1062}1063var SimpleLinkService = function () {1064 function SimpleLinkService() {1065 _classCallCheck(this, SimpleLinkService);1066 }1067 _createClass(SimpleLinkService, [{1068 key: 'navigateTo',1069 value: function navigateTo(dest) {}1070 }, {1071 key: 'getDestinationHash',1072 value: function getDestinationHash(dest) {1073 return '#';1074 }1075 }, {1076 key: 'getAnchorUrl',1077 value: function getAnchorUrl(hash) {1078 return '#';1079 }1080 }, {1081 key: 'setHash',1082 value: function setHash(hash) {}1083 }, {1084 key: 'executeNamedAction',1085 value: function executeNamedAction(action) {}1086 }, {1087 key: 'onFileAttachmentAnnotation',1088 value: function onFileAttachmentAnnotation(_ref4) {1089 var id = _ref4.id,1090 filename = _ref4.filename,1091 content = _ref4.content;1092 }1093 }, {1094 key: 'cachePageRef',1095 value: function cachePageRef(pageNum, pageRef) {}1096 }, {1097 key: 'page',1098 get: function get() {1099 return 0;1100 },1101 set: function set(value) {}1102 }, {1103 key: 'rotation',1104 get: function get() {1105 return 0;1106 },1107 set: function set(value) {}1108 }]);1109 return SimpleLinkService;1110}();1111exports.PDFLinkService = PDFLinkService;1112exports.SimpleLinkService = SimpleLinkService;1113/***/ }),1114/* 4 */1115/***/ (function(module, exports, __w_pdfjs_require__) {1116"use strict";1117Object.defineProperty(exports, "__esModule", {1118 value: true1119});1120exports.BaseViewer = undefined;1121var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();1122var _pdfjsLib = __w_pdfjs_require__(0);1123var _ui_utils = __w_pdfjs_require__(1);1124var _pdf_rendering_queue = __w_pdfjs_require__(5);1125var _annotation_layer_builder = __w_pdfjs_require__(6);1126var _dom_events = __w_pdfjs_require__(2);1127var _pdf_page_view = __w_pdfjs_require__(7);1128var _pdf_link_service = __w_pdfjs_require__(3);1129var _text_layer_builder = __w_pdfjs_require__(8);1130function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }1131var DEFAULT_CACHE_SIZE = 10;1132function PDFPageViewBuffer(size) {1133 var data = [];1134 this.push = function (view) {1135 var i = data.indexOf(view);1136 if (i >= 0) {1137 data.splice(i, 1);1138 }1139 data.push(view);1140 if (data.length > size) {1141 data.shift().destroy();1142 }1143 };1144 this.resize = function (newSize) {1145 size = newSize;1146 while (data.length > size) {1147 data.shift().destroy();1148 }1149 };1150}1151function isSameScale(oldScale, newScale) {1152 if (newScale === oldScale) {1153 return true;1154 }1155 if (Math.abs(newScale - oldScale) < 1e-15) {1156 return true;1157 }1158 return false;1159}1160function isPortraitOrientation(size) {1161 return size.width <= size.height;1162}1163var BaseViewer = function () {1164 function BaseViewer(options) {1165 _classCallCheck(this, BaseViewer);1166 if (this.constructor === BaseViewer) {1167 throw new Error('Cannot initialize BaseViewer.');1168 }1169 this._name = this.constructor.name;1170 this.container = options.container;1171 this.viewer = options.viewer || options.container.firstElementChild;1172 this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();1173 this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();1174 this.downloadManager = options.downloadManager || null;1175 this.removePageBorders = options.removePageBorders || false;1176 this.enhanceTextSelection = options.enhanceTextSelection || false;1177 this.renderInteractiveForms = options.renderInteractiveForms || false;1178 this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;1179 this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;1180 this.l10n = options.l10n || _ui_utils.NullL10n;1181 this.defaultRenderingQueue = !options.renderingQueue;1182 if (this.defaultRenderingQueue) {1183 this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();1184 this.renderingQueue.setViewer(this);1185 } else {1186 this.renderingQueue = options.renderingQueue;1187 }1188 this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));1189 this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;1190 this._resetView();1191 if (this.removePageBorders) {1192 this.viewer.classList.add('removePageBorders');1193 }1194 }1195 _createClass(BaseViewer, [{1196 key: 'getPageView',1197 value: function getPageView(index) {1198 return this._pages[index];1199 }1200 }, {1201 key: '_setCurrentPageNumber',1202 value: function _setCurrentPageNumber(val) {1203 var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;1204 if (this._currentPageNumber === val) {1205 if (resetCurrentPageView) {1206 this._resetCurrentPageView();1207 }1208 return;1209 }1210 if (!(0 < val && val <= this.pagesCount)) {1211 console.error(this._name + '._setCurrentPageNumber: "' + val + '" is out of bounds.');1212 return;1213 }1214 var arg = {1215 source: this,1216 pageNumber: val,1217 pageLabel: this._pageLabels && this._pageLabels[val - 1]1218 };1219 this._currentPageNumber = val;1220 this.eventBus.dispatch('pagechanging', arg);1221 this.eventBus.dispatch('pagechange', arg);1222 if (resetCurrentPageView) {1223 this._resetCurrentPageView();1224 }1225 }1226 }, {1227 key: 'setDocument',1228 value: function setDocument(pdfDocument) {1229 var _this = this;1230 if (this.pdfDocument) {1231 this._cancelRendering();1232 this._resetView();1233 }1234 this.pdfDocument = pdfDocument;1235 if (!pdfDocument) {1236 return;1237 }1238 var pagesCount = pdfDocument.numPages;1239 var pagesCapability = (0, _pdfjsLib.createPromiseCapability)();1240 this.pagesPromise = pagesCapability.promise;1241 pagesCapability.promise.then(function () {1242 _this._pageViewsReady = true;1243 _this.eventBus.dispatch('pagesloaded', {1244 source: _this,1245 pagesCount: pagesCount1246 });1247 });1248 var isOnePageRenderedResolved = false;1249 var onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();1250 this.onePageRendered = onePageRenderedCapability.promise;1251 var bindOnAfterAndBeforeDraw = function bindOnAfterAndBeforeDraw(pageView) {1252 pageView.onBeforeDraw = function () {1253 _this._buffer.push(pageView);1254 };1255 pageView.onAfterDraw = function () {1256 if (!isOnePageRenderedResolved) {1257 isOnePageRenderedResolved = true;1258 onePageRenderedCapability.resolve();1259 }1260 };1261 };1262 var firstPagePromise = pdfDocument.getPage(1);1263 this.firstPagePromise = firstPagePromise;1264 firstPagePromise.then(function (pdfPage) {1265 var scale = _this.currentScale;1266 var viewport = pdfPage.getViewport(scale * _ui_utils.CSS_UNITS);1267 for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {1268 var textLayerFactory = null;1269 if (!_pdfjsLib.PDFJS.disableTextLayer) {1270 textLayerFactory = _this;1271 }1272 var pageView = new _pdf_page_view.PDFPageView({1273 container: _this._setDocumentViewerElement,1274 eventBus: _this.eventBus,1275 id: pageNum,1276 scale: scale,1277 defaultViewport: viewport.clone(),1278 renderingQueue: _this.renderingQueue,1279 textLayerFactory: textLayerFactory,1280 annotationLayerFactory: _this,1281 enhanceTextSelection: _this.enhanceTextSelection,1282 renderInteractiveForms: _this.renderInteractiveForms,1283 renderer: _this.renderer,1284 l10n: _this.l10n1285 });1286 bindOnAfterAndBeforeDraw(pageView);1287 _this._pages.push(pageView);1288 }1289 onePageRenderedCapability.promise.then(function () {1290 if (_pdfjsLib.PDFJS.disableAutoFetch) {1291 pagesCapability.resolve();1292 return;1293 }1294 var getPagesLeft = pagesCount;1295 var _loop = function _loop(_pageNum) {1296 pdfDocument.getPage(_pageNum).then(function (pdfPage) {1297 var pageView = _this._pages[_pageNum - 1];1298 if (!pageView.pdfPage) {1299 pageView.setPdfPage(pdfPage);1300 }1301 _this.linkService.cachePageRef(_pageNum, pdfPage.ref);1302 if (--getPagesLeft === 0) {1303 pagesCapability.resolve();1304 }1305 }, function (reason) {1306 console.error('Unable to get page ' + _pageNum + ' to initialize viewer', reason);1307 if (--getPagesLeft === 0) {1308 pagesCapability.resolve();1309 }1310 });1311 };1312 for (var _pageNum = 1; _pageNum <= pagesCount; ++_pageNum) {1313 _loop(_pageNum);1314 }1315 });1316 _this.eventBus.dispatch('pagesinit', { source: _this });1317 if (_this.defaultRenderingQueue) {1318 _this.update();1319 }1320 if (_this.findController) {1321 _this.findController.resolveFirstPage();1322 }1323 }).catch(function (reason) {1324 console.error('Unable to initialize viewer', reason);1325 });1326 }1327 }, {1328 key: 'setPageLabels',1329 value: function setPageLabels(labels) {1330 if (!this.pdfDocument) {1331 return;1332 }1333 if (!labels) {1334 this._pageLabels = null;1335 } else if (!(labels instanceof Array && this.pdfDocument.numPages === labels.length)) {1336 this._pageLabels = null;1337 console.error(this._name + '.setPageLabels: Invalid page labels.');1338 } else {1339 this._pageLabels = labels;1340 }1341 for (var i = 0, ii = this._pages.length; i < ii; i++) {1342 var pageView = this._pages[i];1343 var label = this._pageLabels && this._pageLabels[i];1344 pageView.setPageLabel(label);1345 }1346 }1347 }, {1348 key: '_resetView',1349 value: function _resetView() {1350 this._pages = [];1351 this._currentPageNumber = 1;1352 this._currentScale = _ui_utils.UNKNOWN_SCALE;1353 this._currentScaleValue = null;1354 this._pageLabels = null;1355 this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);1356 this._location = null;1357 this._pagesRotation = 0;1358 this._pagesRequests = [];1359 this._pageViewsReady = false;1360 this.viewer.textContent = '';1361 }1362 }, {1363 key: '_scrollUpdate',1364 value: function _scrollUpdate() {1365 if (this.pagesCount === 0) {1366 return;1367 }1368 this.update();1369 }1370 }, {1371 key: '_scrollIntoView',1372 value: function _scrollIntoView(_ref) {1373 var pageDiv = _ref.pageDiv,1374 _ref$pageSpot = _ref.pageSpot,1375 pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot,1376 _ref$pageNumber = _ref.pageNumber,1377 pageNumber = _ref$pageNumber === undefined ? null : _ref$pageNumber;1378 throw new Error('Not implemented: _scrollIntoView');1379 }1380 }, {1381 key: '_setScaleDispatchEvent',1382 value: function _setScaleDispatchEvent(newScale, newValue) {1383 var preset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;1384 var arg = {1385 source: this,1386 scale: newScale,1387 presetValue: preset ? newValue : undefined1388 };1389 this.eventBus.dispatch('scalechanging', arg);1390 this.eventBus.dispatch('scalechange', arg);1391 }1392 }, {1393 key: '_setScaleUpdatePages',1394 value: function _setScaleUpdatePages(newScale, newValue) {1395 var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;1396 var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;1397 this._currentScaleValue = newValue.toString();1398 if (isSameScale(this._currentScale, newScale)) {1399 if (preset) {1400 this._setScaleDispatchEvent(newScale, newValue, true);1401 }1402 return;1403 }1404 for (var i = 0, ii = this._pages.length; i < ii; i++) {1405 this._pages[i].update(newScale);1406 }1407 this._currentScale = newScale;1408 if (!noScroll) {1409 var page = this._currentPageNumber,1410 dest = void 0;1411 if (this._location && !_pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom && !(this.isInPresentationMode || this.isChangingPresentationMode)) {1412 page = this._location.pageNumber;1413 dest = [null, { name: 'XYZ' }, this._location.left, this._location.top, null];1414 }1415 this.scrollPageIntoView({1416 pageNumber: page,1417 destArray: dest,1418 allowNegativeOffset: true1419 });1420 }1421 this._setScaleDispatchEvent(newScale, newValue, preset);1422 if (this.defaultRenderingQueue) {1423 this.update();1424 }1425 }1426 }, {1427 key: '_setScale',1428 value: function _setScale(value) {1429 var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;1430 var scale = parseFloat(value);1431 if (scale > 0) {1432 this._setScaleUpdatePages(scale, value, noScroll, false);1433 } else {1434 var currentPage = this._pages[this._currentPageNumber - 1];1435 if (!currentPage) {1436 return;1437 }1438 var hPadding = this.isInPresentationMode || this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;1439 var vPadding = this.isInPresentationMode || this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;1440 var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;1441 var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;1442 switch (value) {1443 case 'page-actual':1444 scale = 1;1445 break;1446 case 'page-width':1447 scale = pageWidthScale;1448 break;1449 case 'page-height':1450 scale = pageHeightScale;1451 break;1452 case 'page-fit':1453 scale = Math.min(pageWidthScale, pageHeightScale);1454 break;1455 case 'auto':1456 var isLandscape = currentPage.width > currentPage.height;1457 var horizontalScale = isLandscape ? Math.min(pageHeightScale, pageWidthScale) : pageWidthScale;1458 scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);1459 break;1460 default:1461 console.error(this._name + '._setScale: "' + value + '" is an unknown zoom value.');1462 return;1463 }1464 this._setScaleUpdatePages(scale, value, noScroll, true);1465 }1466 }1467 }, {1468 key: '_resetCurrentPageView',1469 value: function _resetCurrentPageView() {1470 if (this.isInPresentationMode) {1471 this._setScale(this._currentScaleValue, true);1472 }1473 var pageView = this._pages[this._currentPageNumber - 1];1474 this._scrollIntoView({ pageDiv: pageView.div });1475 }1476 }, {1477 key: 'scrollPageIntoView',1478 value: function scrollPageIntoView(params) {1479 if (arguments.length > 1 || typeof params === 'number') {1480 console.error('Call of scrollPageIntoView() with obsolete signature.');1481 return;1482 }1483 if (!this.pdfDocument) {1484 return;1485 }1486 var pageNumber = params.pageNumber || 0;1487 var dest = params.destArray || null;1488 var allowNegativeOffset = params.allowNegativeOffset || false;1489 if (this.isInPresentationMode || !dest) {1490 this._setCurrentPageNumber(pageNumber, true);1491 return;1492 }1493 var pageView = this._pages[pageNumber - 1];1494 if (!pageView) {1495 console.error(this._name + '.scrollPageIntoView: Invalid "pageNumber" parameter.');1496 return;1497 }1498 var x = 0,1499 y = 0;1500 var width = 0,1501 height = 0,1502 widthScale = void 0,1503 heightScale = void 0;1504 var changeOrientation = pageView.rotation % 180 === 0 ? false : true;1505 var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;1506 var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;1507 var scale = 0;1508 switch (dest[1].name) {1509 case 'XYZ':1510 x = dest[2];1511 y = dest[3];1512 scale = dest[4];1513 x = x !== null ? x : 0;1514 y = y !== null ? y : pageHeight;1515 break;1516 case 'Fit':1517 case 'FitB':1518 scale = 'page-fit';1519 break;1520 case 'FitH':1521 case 'FitBH':1522 y = dest[2];1523 scale = 'page-width';1524 if (y === null && this._location) {1525 x = this._location.left;1526 y = this._location.top;1527 }1528 break;1529 case 'FitV':1530 case 'FitBV':1531 x = dest[2];1532 width = pageWidth;1533 height = pageHeight;1534 scale = 'page-height';1535 break;1536 case 'FitR':1537 x = dest[2];1538 y = dest[3];1539 width = dest[4] - x;1540 height = dest[5] - y;1541 var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;1542 var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;1543 widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;1544 heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;1545 scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));1546 break;1547 default:1548 console.error(this._name + '.scrollPageIntoView: "' + dest[1].name + '" ' + 'is not a valid destination type.');1549 return;1550 }1551 if (scale && scale !== this._currentScale) {1552 this.currentScaleValue = scale;1553 } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {1554 this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;1555 }1556 if (scale === 'page-fit' && !dest[4]) {1557 this._scrollIntoView({1558 pageDiv: pageView.div,1559 pageNumber: pageNumber1560 });1561 return;1562 }1563 var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];1564 var left = Math.min(boundingRect[0][0], boundingRect[1][0]);1565 var top = Math.min(boundingRect[0][1], boundingRect[1][1]);1566 if (!allowNegativeOffset) {1567 left = Math.max(left, 0);1568 top = Math.max(top, 0);1569 }1570 this._scrollIntoView({1571 pageDiv: pageView.div,1572 pageSpot: {1573 left: left,1574 top: top1575 },1576 pageNumber: pageNumber1577 });1578 }1579 }, {1580 key: '_resizeBuffer',1581 value: function _resizeBuffer(numVisiblePages) {1582 var suggestedCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);1583 this._buffer.resize(suggestedCacheSize);1584 }1585 }, {1586 key: '_updateLocation',1587 value: function _updateLocation(firstPage) {1588 var currentScale = this._currentScale;1589 var currentScaleValue = this._currentScaleValue;1590 var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;1591 var pageNumber = firstPage.id;1592 var pdfOpenParams = '#page=' + pageNumber;1593 pdfOpenParams += '&zoom=' + normalizedScaleValue;1594 var currentPageView = this._pages[pageNumber - 1];1595 var container = this.container;1596 var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);1597 var intLeft = Math.round(topLeft[0]);1598 var intTop = Math.round(topLeft[1]);1599 pdfOpenParams += ',' + intLeft + ',' + intTop;1600 this._location = {1601 pageNumber: pageNumber,1602 scale: normalizedScaleValue,1603 top: intTop,1604 left: intLeft,1605 rotation: this._pagesRotation,1606 pdfOpenParams: pdfOpenParams1607 };1608 }1609 }, {1610 key: 'update',1611 value: function update() {1612 throw new Error('Not implemented: update');1613 }1614 }, {1615 key: 'containsElement',1616 value: function containsElement(element) {1617 return this.container.contains(element);1618 }1619 }, {1620 key: 'focus',1621 value: function focus() {1622 this.container.focus();1623 }1624 }, {1625 key: '_getVisiblePages',1626 value: function _getVisiblePages() {1627 throw new Error('Not implemented: _getVisiblePages');1628 }1629 }, {1630 key: 'cleanup',1631 value: function cleanup() {1632 for (var i = 0, ii = this._pages.length; i < ii; i++) {1633 if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {1634 this._pages[i].reset();1635 }1636 }1637 }1638 }, {1639 key: '_cancelRendering',1640 value: function _cancelRendering() {1641 for (var i = 0, ii = this._pages.length; i < ii; i++) {1642 if (this._pages[i]) {1643 this._pages[i].cancelRendering();1644 }1645 }1646 }1647 }, {1648 key: '_ensurePdfPageLoaded',1649 value: function _ensurePdfPageLoaded(pageView) {1650 var _this2 = this;1651 if (pageView.pdfPage) {1652 return Promise.resolve(pageView.pdfPage);1653 }1654 var pageNumber = pageView.id;1655 if (this._pagesRequests[pageNumber]) {1656 return this._pagesRequests[pageNumber];1657 }1658 var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {1659 if (!pageView.pdfPage) {1660 pageView.setPdfPage(pdfPage);1661 }1662 _this2._pagesRequests[pageNumber] = null;1663 return pdfPage;1664 }).catch(function (reason) {1665 console.error('Unable to get page for page view', reason);1666 _this2._pagesRequests[pageNumber] = null;1667 });1668 this._pagesRequests[pageNumber] = promise;1669 return promise;1670 }1671 }, {1672 key: 'forceRendering',1673 value: function forceRendering(currentlyVisiblePages) {1674 var _this3 = this;1675 var visiblePages = currentlyVisiblePages || this._getVisiblePages();1676 var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, this.scroll.down);1677 if (pageView) {1678 this._ensurePdfPageLoaded(pageView).then(function () {1679 _this3.renderingQueue.renderView(pageView);1680 });1681 return true;1682 }1683 return false;1684 }1685 }, {1686 key: 'getPageTextContent',1687 value: function getPageTextContent(pageIndex) {1688 return this.pdfDocument.getPage(pageIndex + 1).then(function (page) {1689 return page.getTextContent({ normalizeWhitespace: true });1690 });1691 }1692 }, {1693 key: 'createTextLayerBuilder',1694 value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {1695 var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;1696 return new _text_layer_builder.TextLayerBuilder({1697 textLayerDiv: textLayerDiv,1698 eventBus: this.eventBus,1699 pageIndex: pageIndex,1700 viewport: viewport,1701 findController: this.isInPresentationMode ? null : this.findController,1702 enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection1703 });1704 }1705 }, {1706 key: 'createAnnotationLayerBuilder',1707 value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {1708 var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;1709 var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;1710 return new _annotation_layer_builder.AnnotationLayerBuilder({1711 pageDiv: pageDiv,1712 pdfPage: pdfPage,1713 renderInteractiveForms: renderInteractiveForms,1714 linkService: this.linkService,1715 downloadManager: this.downloadManager,1716 l10n: l10n1717 });1718 }1719 }, {1720 key: 'setFindController',1721 value: function setFindController(findController) {1722 this.findController = findController;1723 }1724 }, {1725 key: 'getPagesOverview',1726 value: function getPagesOverview() {1727 var pagesOverview = this._pages.map(function (pageView) {1728 var viewport = pageView.pdfPage.getViewport(1);1729 return {1730 width: viewport.width,1731 height: viewport.height,1732 rotation: viewport.rotation1733 };1734 });1735 if (!this.enablePrintAutoRotate) {1736 return pagesOverview;1737 }1738 var isFirstPagePortrait = isPortraitOrientation(pagesOverview[0]);1739 return pagesOverview.map(function (size) {1740 if (isFirstPagePortrait === isPortraitOrientation(size)) {1741 return size;1742 }1743 return {1744 width: size.height,1745 height: size.width,1746 rotation: (size.rotation + 90) % 3601747 };1748 });1749 }1750 }, {1751 key: 'pagesCount',1752 get: function get() {1753 return this._pages.length;1754 }1755 }, {1756 key: 'pageViewsReady',1757 get: function get() {1758 return this._pageViewsReady;1759 }1760 }, {1761 key: 'currentPageNumber',1762 get: function get() {1763 return this._currentPageNumber;1764 },1765 set: function set(val) {1766 if (!Number.isInteger(val)) {1767 throw new Error('Invalid page number.');1768 }1769 if (!this.pdfDocument) {1770 return;1771 }1772 this._setCurrentPageNumber(val, true);1773 }1774 }, {1775 key: 'currentPageLabel',1776 get: function get() {1777 return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];1778 },1779 set: function set(val) {1780 var pageNumber = val | 0;1781 if (this._pageLabels) {1782 var i = this._pageLabels.indexOf(val);1783 if (i >= 0) {1784 pageNumber = i + 1;1785 }1786 }1787 this.currentPageNumber = pageNumber;1788 }1789 }, {1790 key: 'currentScale',1791 get: function get() {1792 return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;1793 },1794 set: function set(val) {1795 if (isNaN(val)) {1796 throw new Error('Invalid numeric scale');1797 }1798 if (!this.pdfDocument) {1799 return;1800 }1801 this._setScale(val, false);1802 }1803 }, {1804 key: 'currentScaleValue',1805 get: function get() {1806 return this._currentScaleValue;1807 },1808 set: function set(val) {1809 if (!this.pdfDocument) {1810 return;1811 }1812 this._setScale(val, false);1813 }1814 }, {1815 key: 'pagesRotation',1816 get: function get() {1817 return this._pagesRotation;1818 },1819 set: function set(rotation) {1820 if (!(0, _ui_utils.isValidRotation)(rotation)) {1821 throw new Error('Invalid pages rotation angle.');1822 }1823 if (!this.pdfDocument) {1824 return;1825 }1826 if (this._pagesRotation === rotation) {1827 return;1828 }1829 this._pagesRotation = rotation;1830 var pageNumber = this._currentPageNumber;1831 for (var i = 0, ii = this._pages.length; i < ii; i++) {1832 var pageView = this._pages[i];1833 pageView.update(pageView.scale, rotation);1834 }1835 if (this._currentScaleValue) {1836 this._setScale(this._currentScaleValue, true);1837 }1838 this.eventBus.dispatch('rotationchanging', {1839 source: this,1840 pagesRotation: rotation,1841 pageNumber: pageNumber1842 });1843 if (this.defaultRenderingQueue) {1844 this.update();1845 }1846 }1847 }, {1848 key: '_setDocumentViewerElement',1849 get: function get() {1850 throw new Error('Not implemented: _setDocumentViewerElement');1851 }1852 }, {1853 key: 'isInPresentationMode',1854 get: function get() {1855 return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;1856 }1857 }, {1858 key: 'isChangingPresentationMode',1859 get: function get() {1860 return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;1861 }1862 }, {1863 key: 'isHorizontalScrollbarEnabled',1864 get: function get() {1865 return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;1866 }1867 }, {1868 key: 'hasEqualPageSizes',1869 get: function get() {1870 var firstPageView = this._pages[0];1871 for (var i = 1, ii = this._pages.length; i < ii; ++i) {1872 var pageView = this._pages[i];1873 if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {1874 return false;1875 }1876 }1877 return true;1878 }1879 }]);1880 return BaseViewer;1881}();1882exports.BaseViewer = BaseViewer;1883/***/ }),1884/* 5 */1885/***/ (function(module, exports, __w_pdfjs_require__) {1886"use strict";1887Object.defineProperty(exports, "__esModule", {1888 value: true1889});1890var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();1891function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }1892var CLEANUP_TIMEOUT = 30000;1893var RenderingStates = {1894 INITIAL: 0,1895 RUNNING: 1,1896 PAUSED: 2,1897 FINISHED: 31898};1899var PDFRenderingQueue = function () {1900 function PDFRenderingQueue() {1901 _classCallCheck(this, PDFRenderingQueue);1902 this.pdfViewer = null;1903 this.pdfThumbnailViewer = null;1904 this.onIdle = null;1905 this.highestPriorityPage = null;1906 this.idleTimeout = null;1907 this.printing = false;1908 this.isThumbnailViewEnabled = false;1909 }1910 _createClass(PDFRenderingQueue, [{1911 key: "setViewer",1912 value: function setViewer(pdfViewer) {1913 this.pdfViewer = pdfViewer;1914 }1915 }, {1916 key: "setThumbnailViewer",1917 value: function setThumbnailViewer(pdfThumbnailViewer) {1918 this.pdfThumbnailViewer = pdfThumbnailViewer;1919 }1920 }, {1921 key: "isHighestPriority",1922 value: function isHighestPriority(view) {1923 return this.highestPriorityPage === view.renderingId;1924 }1925 }, {1926 key: "renderHighestPriority",1927 value: function renderHighestPriority(currentlyVisiblePages) {1928 if (this.idleTimeout) {1929 clearTimeout(this.idleTimeout);1930 this.idleTimeout = null;1931 }1932 if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {1933 return;1934 }1935 if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {1936 if (this.pdfThumbnailViewer.forceRendering()) {1937 return;1938 }1939 }1940 if (this.printing) {1941 return;1942 }1943 if (this.onIdle) {1944 this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);1945 }1946 }1947 }, {1948 key: "getHighestPriority",1949 value: function getHighestPriority(visible, views, scrolledDown) {1950 var visibleViews = visible.views;1951 var numVisible = visibleViews.length;1952 if (numVisible === 0) {1953 return false;1954 }1955 for (var i = 0; i < numVisible; ++i) {1956 var view = visibleViews[i].view;1957 if (!this.isViewFinished(view)) {1958 return view;1959 }1960 }1961 if (scrolledDown) {1962 var nextPageIndex = visible.last.id;1963 if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {1964 return views[nextPageIndex];1965 }1966 } else {1967 var previousPageIndex = visible.first.id - 2;1968 if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {1969 return views[previousPageIndex];1970 }1971 }1972 return null;1973 }1974 }, {1975 key: "isViewFinished",1976 value: function isViewFinished(view) {1977 return view.renderingState === RenderingStates.FINISHED;1978 }1979 }, {1980 key: "renderView",1981 value: function renderView(view) {1982 var _this = this;1983 switch (view.renderingState) {1984 case RenderingStates.FINISHED:1985 return false;1986 case RenderingStates.PAUSED:1987 this.highestPriorityPage = view.renderingId;1988 view.resume();1989 break;1990 case RenderingStates.RUNNING:1991 this.highestPriorityPage = view.renderingId;1992 break;1993 case RenderingStates.INITIAL:1994 this.highestPriorityPage = view.renderingId;1995 var continueRendering = function continueRendering() {1996 _this.renderHighestPriority();1997 };1998 view.draw().then(continueRendering, continueRendering);1999 break;2000 }2001 return true;2002 }2003 }]);2004 return PDFRenderingQueue;2005}();2006exports.RenderingStates = RenderingStates;2007exports.PDFRenderingQueue = PDFRenderingQueue;2008/***/ }),2009/* 6 */2010/***/ (function(module, exports, __w_pdfjs_require__) {2011"use strict";2012Object.defineProperty(exports, "__esModule", {2013 value: true2014});2015exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = undefined;2016var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();2017var _pdfjsLib = __w_pdfjs_require__(0);2018var _ui_utils = __w_pdfjs_require__(1);2019var _pdf_link_service = __w_pdfjs_require__(3);2020function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }2021var AnnotationLayerBuilder = function () {2022 function AnnotationLayerBuilder(_ref) {2023 var pageDiv = _ref.pageDiv,2024 pdfPage = _ref.pdfPage,2025 linkService = _ref.linkService,2026 downloadManager = _ref.downloadManager,2027 _ref$renderInteractiv = _ref.renderInteractiveForms,2028 renderInteractiveForms = _ref$renderInteractiv === undefined ? false : _ref$renderInteractiv,2029 _ref$l10n = _ref.l10n,2030 l10n = _ref$l10n === undefined ? _ui_utils.NullL10n : _ref$l10n;2031 _classCallCheck(this, AnnotationLayerBuilder);2032 this.pageDiv = pageDiv;2033 this.pdfPage = pdfPage;2034 this.linkService = linkService;2035 this.downloadManager = downloadManager;2036 this.renderInteractiveForms = renderInteractiveForms;2037 this.l10n = l10n;2038 this.div = null;2039 this._cancelled = false;2040 }2041 _createClass(AnnotationLayerBuilder, [{2042 key: 'render',2043 value: function render(viewport) {2044 var _this = this;2045 var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'display';2046 this.pdfPage.getAnnotations({ intent: intent }).then(function (annotations) {2047 if (_this._cancelled) {2048 return;2049 }2050 var parameters = {2051 viewport: viewport.clone({ dontFlip: true }),2052 div: _this.div,2053 annotations: annotations,2054 page: _this.pdfPage,2055 renderInteractiveForms: _this.renderInteractiveForms,2056 linkService: _this.linkService,2057 downloadManager: _this.downloadManager2058 };2059 if (_this.div) {2060 _pdfjsLib.AnnotationLayer.update(parameters);2061 } else {2062 if (annotations.length === 0) {2063 return;2064 }2065 _this.div = document.createElement('div');2066 _this.div.className = 'annotationLayer';2067 _this.pageDiv.appendChild(_this.div);2068 parameters.div = _this.div;2069 _pdfjsLib.AnnotationLayer.render(parameters);2070 _this.l10n.translate(_this.div);2071 }2072 });2073 }2074 }, {2075 key: 'cancel',2076 value: function cancel() {2077 this._cancelled = true;2078 }2079 }, {2080 key: 'hide',2081 value: function hide() {2082 if (!this.div) {2083 return;2084 }2085 this.div.setAttribute('hidden', 'true');2086 }2087 }]);2088 return AnnotationLayerBuilder;2089}();2090var DefaultAnnotationLayerFactory = function () {2091 function DefaultAnnotationLayerFactory() {2092 _classCallCheck(this, DefaultAnnotationLayerFactory);2093 }2094 _createClass(DefaultAnnotationLayerFactory, [{2095 key: 'createAnnotationLayerBuilder',2096 value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {2097 var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;2098 var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;2099 return new AnnotationLayerBuilder({2100 pageDiv: pageDiv,2101 pdfPage: pdfPage,2102 renderInteractiveForms: renderInteractiveForms,2103 linkService: new _pdf_link_service.SimpleLinkService(),2104 l10n: l10n2105 });2106 }2107 }]);2108 return DefaultAnnotationLayerFactory;2109}();2110exports.AnnotationLayerBuilder = AnnotationLayerBuilder;2111exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;2112/***/ }),2113/* 7 */2114/***/ (function(module, exports, __w_pdfjs_require__) {2115"use strict";2116Object.defineProperty(exports, "__esModule", {2117 value: true2118});2119exports.PDFPageView = undefined;2120var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();2121var _ui_utils = __w_pdfjs_require__(1);2122var _pdfjsLib = __w_pdfjs_require__(0);2123var _dom_events = __w_pdfjs_require__(2);2124var _pdf_rendering_queue = __w_pdfjs_require__(5);2125function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }2126var PDFPageView = function () {2127 function PDFPageView(options) {2128 _classCallCheck(this, PDFPageView);2129 var container = options.container;2130 var defaultViewport = options.defaultViewport;2131 this.id = options.id;2132 this.renderingId = 'page' + this.id;2133 this.pdfPage = null;2134 this.pageLabel = null;2135 this.rotation = 0;2136 this.scale = options.scale || _ui_utils.DEFAULT_SCALE;2137 this.viewport = defaultViewport;2138 this.pdfPageRotate = defaultViewport.rotation;2139 this.hasRestrictedScaling = false;2140 this.enhanceTextSelection = options.enhanceTextSelection || false;2141 this.renderInteractiveForms = options.renderInteractiveForms || false;2142 this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();2143 this.renderingQueue = options.renderingQueue;2144 this.textLayerFactory = options.textLayerFactory;2145 this.annotationLayerFactory = options.annotationLayerFactory;2146 this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;2147 this.l10n = options.l10n || _ui_utils.NullL10n;2148 this.paintTask = null;2149 this.paintedViewportMap = new WeakMap();2150 this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;2151 this.resume = null;2152 this.error = null;2153 this.onBeforeDraw = null;2154 this.onAfterDraw = null;2155 this.annotationLayer = null;2156 this.textLayer = null;2157 this.zoomLayer = null;2158 var div = document.createElement('div');2159 div.className = 'page';2160 div.style.width = Math.floor(this.viewport.width) + 'px';2161 div.style.height = Math.floor(this.viewport.height) + 'px';2162 div.setAttribute('data-page-number', this.id);2163 this.div = div;2164 container.appendChild(div);2165 }2166 _createClass(PDFPageView, [{2167 key: 'setPdfPage',2168 value: function setPdfPage(pdfPage) {2169 this.pdfPage = pdfPage;2170 this.pdfPageRotate = pdfPage.rotate;2171 var totalRotation = (this.rotation + this.pdfPageRotate) % 360;2172 this.viewport = pdfPage.getViewport(this.scale * _ui_utils.CSS_UNITS, totalRotation);2173 this.stats = pdfPage.stats;2174 this.reset();2175 }2176 }, {2177 key: 'destroy',2178 value: function destroy() {2179 this.reset();2180 if (this.pdfPage) {2181 this.pdfPage.cleanup();2182 }2183 }2184 }, {2185 key: '_resetZoomLayer',2186 value: function _resetZoomLayer() {2187 var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;2188 if (!this.zoomLayer) {2189 return;2190 }2191 var zoomLayerCanvas = this.zoomLayer.firstChild;2192 this.paintedViewportMap.delete(zoomLayerCanvas);2193 zoomLayerCanvas.width = 0;2194 zoomLayerCanvas.height = 0;2195 if (removeFromDOM) {2196 this.zoomLayer.remove();2197 }2198 this.zoomLayer = null;2199 }2200 }, {2201 key: 'reset',2202 value: function reset() {2203 var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;2204 var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;2205 this.cancelRendering(keepAnnotations);2206 var div = this.div;2207 div.style.width = Math.floor(this.viewport.width) + 'px';2208 div.style.height = Math.floor(this.viewport.height) + 'px';2209 var childNodes = div.childNodes;2210 var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;2211 var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;2212 for (var i = childNodes.length - 1; i >= 0; i--) {2213 var node = childNodes[i];2214 if (currentZoomLayerNode === node || currentAnnotationNode === node) {2215 continue;2216 }2217 div.removeChild(node);2218 }2219 div.removeAttribute('data-loaded');2220 if (currentAnnotationNode) {2221 this.annotationLayer.hide();2222 } else if (this.annotationLayer) {2223 this.annotationLayer.cancel();2224 this.annotationLayer = null;2225 }2226 if (!currentZoomLayerNode) {2227 if (this.canvas) {2228 this.paintedViewportMap.delete(this.canvas);2229 this.canvas.width = 0;2230 this.canvas.height = 0;2231 delete this.canvas;2232 }2233 this._resetZoomLayer();2234 }2235 if (this.svg) {2236 this.paintedViewportMap.delete(this.svg);2237 delete this.svg;2238 }2239 this.loadingIconDiv = document.createElement('div');2240 this.loadingIconDiv.className = 'loadingIcon';2241 div.appendChild(this.loadingIconDiv);2242 }2243 }, {2244 key: 'update',2245 value: function update(scale, rotation) {2246 this.scale = scale || this.scale;2247 if (typeof rotation !== 'undefined') {2248 this.rotation = rotation;2249 }2250 var totalRotation = (this.rotation + this.pdfPageRotate) % 360;2251 this.viewport = this.viewport.clone({2252 scale: this.scale * _ui_utils.CSS_UNITS,2253 rotation: totalRotation2254 });2255 if (this.svg) {2256 this.cssTransform(this.svg, true);2257 this.eventBus.dispatch('pagerendered', {2258 source: this,2259 pageNumber: this.id,2260 cssTransform: true2261 });2262 return;2263 }2264 var isScalingRestricted = false;2265 if (this.canvas && _pdfjsLib.PDFJS.maxCanvasPixels > 0) {2266 var outputScale = this.outputScale;2267 if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > _pdfjsLib.PDFJS.maxCanvasPixels) {2268 isScalingRestricted = true;2269 }2270 }2271 if (this.canvas) {2272 if (_pdfjsLib.PDFJS.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {2273 this.cssTransform(this.canvas, true);2274 this.eventBus.dispatch('pagerendered', {2275 source: this,2276 pageNumber: this.id,2277 cssTransform: true2278 });2279 return;2280 }2281 if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {2282 this.zoomLayer = this.canvas.parentNode;2283 this.zoomLayer.style.position = 'absolute';2284 }2285 }2286 if (this.zoomLayer) {2287 this.cssTransform(this.zoomLayer.firstChild);2288 }2289 this.reset(true, true);2290 }2291 }, {2292 key: 'cancelRendering',2293 value: function cancelRendering() {2294 var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;2295 if (this.paintTask) {2296 this.paintTask.cancel();2297 this.paintTask = null;2298 }2299 this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;2300 this.resume = null;2301 if (this.textLayer) {2302 this.textLayer.cancel();2303 this.textLayer = null;2304 }2305 if (!keepAnnotations && this.annotationLayer) {2306 this.annotationLayer.cancel();2307 this.annotationLayer = null;2308 }2309 }2310 }, {2311 key: 'cssTransform',2312 value: function cssTransform(target) {2313 var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;2314 var width = this.viewport.width;2315 var height = this.viewport.height;2316 var div = this.div;2317 target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + 'px';2318 target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + 'px';2319 var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;2320 var absRotation = Math.abs(relativeRotation);2321 var scaleX = 1,2322 scaleY = 1;2323 if (absRotation === 90 || absRotation === 270) {2324 scaleX = height / width;2325 scaleY = width / height;2326 }2327 var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')';2328 _pdfjsLib.CustomStyle.setProp('transform', target, cssTransform);2329 if (this.textLayer) {2330 var textLayerViewport = this.textLayer.viewport;2331 var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;2332 var textAbsRotation = Math.abs(textRelativeRotation);2333 var scale = width / textLayerViewport.width;2334 if (textAbsRotation === 90 || textAbsRotation === 270) {2335 scale = width / textLayerViewport.height;2336 }2337 var textLayerDiv = this.textLayer.textLayerDiv;2338 var transX = void 0,2339 transY = void 0;2340 switch (textAbsRotation) {2341 case 0:2342 transX = transY = 0;2343 break;2344 case 90:2345 transX = 0;2346 transY = '-' + textLayerDiv.style.height;2347 break;2348 case 180:2349 transX = '-' + textLayerDiv.style.width;2350 transY = '-' + textLayerDiv.style.height;2351 break;2352 case 270:2353 transX = '-' + textLayerDiv.style.width;2354 transY = 0;2355 break;2356 default:2357 console.error('Bad rotation value.');2358 break;2359 }2360 _pdfjsLib.CustomStyle.setProp('transform', textLayerDiv, 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')');2361 _pdfjsLib.CustomStyle.setProp('transformOrigin', textLayerDiv, '0% 0%');2362 }2363 if (redrawAnnotations && this.annotationLayer) {2364 this.annotationLayer.render(this.viewport, 'display');2365 }2366 }2367 }, {2368 key: 'getPagePoint',2369 value: function getPagePoint(x, y) {2370 return this.viewport.convertToPdfPoint(x, y);2371 }2372 }, {2373 key: 'draw',2374 value: function draw() {2375 var _this = this;2376 if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {2377 console.error('Must be in new state before drawing');2378 this.reset();2379 }2380 if (!this.pdfPage) {2381 this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;2382 return Promise.reject(new Error('Page is not loaded'));2383 }2384 this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;2385 var pdfPage = this.pdfPage;2386 var div = this.div;2387 var canvasWrapper = document.createElement('div');2388 canvasWrapper.style.width = div.style.width;2389 canvasWrapper.style.height = div.style.height;2390 canvasWrapper.classList.add('canvasWrapper');2391 if (this.annotationLayer && this.annotationLayer.div) {2392 div.insertBefore(canvasWrapper, this.annotationLayer.div);2393 } else {2394 div.appendChild(canvasWrapper);2395 }2396 var textLayer = null;2397 if (this.textLayerFactory) {2398 var textLayerDiv = document.createElement('div');2399 textLayerDiv.className = 'textLayer';2400 textLayerDiv.style.width = canvasWrapper.style.width;2401 textLayerDiv.style.height = canvasWrapper.style.height;2402 if (this.annotationLayer && this.annotationLayer.div) {2403 div.insertBefore(textLayerDiv, this.annotationLayer.div);2404 } else {2405 div.appendChild(textLayerDiv);2406 }2407 textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.enhanceTextSelection);2408 }2409 this.textLayer = textLayer;2410 var renderContinueCallback = null;2411 if (this.renderingQueue) {2412 renderContinueCallback = function renderContinueCallback(cont) {2413 if (!_this.renderingQueue.isHighestPriority(_this)) {2414 _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;2415 _this.resume = function () {2416 _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;2417 cont();2418 };2419 return;2420 }2421 cont();2422 };2423 }2424 var finishPaintTask = function finishPaintTask(error) {2425 if (paintTask === _this.paintTask) {2426 _this.paintTask = null;2427 }2428 if (error === 'cancelled' || error instanceof _pdfjsLib.RenderingCancelledException) {2429 _this.error = null;2430 return Promise.resolve(undefined);2431 }2432 _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;2433 if (_this.loadingIconDiv) {2434 div.removeChild(_this.loadingIconDiv);2435 delete _this.loadingIconDiv;2436 }2437 _this._resetZoomLayer(true);2438 _this.error = error;2439 _this.stats = pdfPage.stats;2440 if (_this.onAfterDraw) {2441 _this.onAfterDraw();2442 }2443 _this.eventBus.dispatch('pagerendered', {2444 source: _this,2445 pageNumber: _this.id,2446 cssTransform: false2447 });2448 if (error) {2449 return Promise.reject(error);2450 }2451 return Promise.resolve(undefined);2452 };2453 var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);2454 paintTask.onRenderContinue = renderContinueCallback;2455 this.paintTask = paintTask;2456 var resultPromise = paintTask.promise.then(function () {2457 return finishPaintTask(null).then(function () {2458 if (textLayer) {2459 var readableStream = pdfPage.streamTextContent({ normalizeWhitespace: true });2460 textLayer.setTextContentStream(readableStream);2461 textLayer.render();2462 }2463 });2464 }, function (reason) {2465 return finishPaintTask(reason);2466 });2467 if (this.annotationLayerFactory) {2468 if (!this.annotationLayer) {2469 this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.renderInteractiveForms, this.l10n);2470 }2471 this.annotationLayer.render(this.viewport, 'display');2472 }2473 div.setAttribute('data-loaded', true);2474 if (this.onBeforeDraw) {2475 this.onBeforeDraw();2476 }2477 return resultPromise;2478 }2479 }, {2480 key: 'paintOnCanvas',2481 value: function paintOnCanvas(canvasWrapper) {2482 var renderCapability = (0, _pdfjsLib.createPromiseCapability)();2483 var result = {2484 promise: renderCapability.promise,2485 onRenderContinue: function onRenderContinue(cont) {2486 cont();2487 },2488 cancel: function cancel() {2489 renderTask.cancel();2490 }2491 };2492 var viewport = this.viewport;2493 var canvas = document.createElement('canvas');2494 canvas.id = this.renderingId;2495 canvas.setAttribute('hidden', 'hidden');2496 var isCanvasHidden = true;2497 var showCanvas = function showCanvas() {2498 if (isCanvasHidden) {2499 canvas.removeAttribute('hidden');2500 isCanvasHidden = false;2501 }2502 };2503 canvasWrapper.appendChild(canvas);2504 this.canvas = canvas;2505 canvas.mozOpaque = true;2506 var ctx = canvas.getContext('2d', { alpha: false });2507 var outputScale = (0, _ui_utils.getOutputScale)(ctx);2508 this.outputScale = outputScale;2509 if (_pdfjsLib.PDFJS.useOnlyCssZoom) {2510 var actualSizeViewport = viewport.clone({ scale: _ui_utils.CSS_UNITS });2511 outputScale.sx *= actualSizeViewport.width / viewport.width;2512 outputScale.sy *= actualSizeViewport.height / viewport.height;2513 outputScale.scaled = true;2514 }2515 if (_pdfjsLib.PDFJS.maxCanvasPixels > 0) {2516 var pixelsInViewport = viewport.width * viewport.height;2517 var maxScale = Math.sqrt(_pdfjsLib.PDFJS.maxCanvasPixels / pixelsInViewport);2518 if (outputScale.sx > maxScale || outputScale.sy > maxScale) {2519 outputScale.sx = maxScale;2520 outputScale.sy = maxScale;2521 outputScale.scaled = true;2522 this.hasRestrictedScaling = true;2523 } else {2524 this.hasRestrictedScaling = false;2525 }2526 }2527 var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);2528 var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);2529 canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);2530 canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);2531 canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + 'px';2532 canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + 'px';2533 this.paintedViewportMap.set(canvas, viewport);2534 var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];2535 var renderContext = {2536 canvasContext: ctx,2537 transform: transform,2538 viewport: this.viewport,2539 renderInteractiveForms: this.renderInteractiveForms2540 };2541 var renderTask = this.pdfPage.render(renderContext);2542 renderTask.onContinue = function (cont) {2543 showCanvas();2544 if (result.onRenderContinue) {2545 result.onRenderContinue(cont);2546 } else {2547 cont();2548 }2549 };2550 renderTask.promise.then(function () {2551 showCanvas();2552 renderCapability.resolve(undefined);2553 }, function (error) {2554 showCanvas();2555 renderCapability.reject(error);2556 });2557 return result;2558 }2559 }, {2560 key: 'paintOnSvg',2561 value: function paintOnSvg(wrapper) {2562 var _this2 = this;2563 var cancelled = false;2564 var ensureNotCancelled = function ensureNotCancelled() {2565 if (cancelled) {2566 if (_pdfjsLib.PDFJS.pdfjsNext) {2567 throw new _pdfjsLib.RenderingCancelledException('Rendering cancelled, page ' + _this2.id, 'svg');2568 } else {2569 throw 'cancelled';2570 }2571 }2572 };2573 var pdfPage = this.pdfPage;2574 var actualSizeViewport = this.viewport.clone({ scale: _ui_utils.CSS_UNITS });2575 var promise = pdfPage.getOperatorList().then(function (opList) {2576 ensureNotCancelled();2577 var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);2578 return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {2579 ensureNotCancelled();2580 _this2.svg = svg;2581 _this2.paintedViewportMap.set(svg, actualSizeViewport);2582 svg.style.width = wrapper.style.width;2583 svg.style.height = wrapper.style.height;2584 _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;2585 wrapper.appendChild(svg);2586 });2587 });2588 return {2589 promise: promise,2590 onRenderContinue: function onRenderContinue(cont) {2591 cont();2592 },2593 cancel: function cancel() {2594 cancelled = true;2595 }2596 };2597 }2598 }, {2599 key: 'setPageLabel',2600 value: function setPageLabel(label) {2601 this.pageLabel = typeof label === 'string' ? label : null;2602 if (this.pageLabel !== null) {2603 this.div.setAttribute('data-page-label', this.pageLabel);2604 } else {2605 this.div.removeAttribute('data-page-label');2606 }2607 }2608 }, {2609 key: 'width',2610 get: function get() {2611 return this.viewport.width;2612 }2613 }, {2614 key: 'height',2615 get: function get() {2616 return this.viewport.height;2617 }2618 }]);2619 return PDFPageView;2620}();2621exports.PDFPageView = PDFPageView;2622/***/ }),2623/* 8 */2624/***/ (function(module, exports, __w_pdfjs_require__) {2625"use strict";2626Object.defineProperty(exports, "__esModule", {2627 value: true2628});2629exports.DefaultTextLayerFactory = exports.TextLayerBuilder = undefined;2630var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();2631var _dom_events = __w_pdfjs_require__(2);2632var _pdfjsLib = __w_pdfjs_require__(0);2633function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }2634var EXPAND_DIVS_TIMEOUT = 300;2635var TextLayerBuilder = function () {2636 function TextLayerBuilder(_ref) {2637 var textLayerDiv = _ref.textLayerDiv,2638 eventBus = _ref.eventBus,2639 pageIndex = _ref.pageIndex,2640 viewport = _ref.viewport,2641 _ref$findController = _ref.findController,2642 findController = _ref$findController === undefined ? null : _ref$findController,2643 _ref$enhanceTextSelec = _ref.enhanceTextSelection,2644 enhanceTextSelection = _ref$enhanceTextSelec === undefined ? false : _ref$enhanceTextSelec;2645 _classCallCheck(this, TextLayerBuilder);2646 this.textLayerDiv = textLayerDiv;2647 this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();2648 this.textContent = null;2649 this.textContentItemsStr = [];2650 this.textContentStream = null;2651 this.renderingDone = false;2652 this.pageIdx = pageIndex;2653 this.pageNumber = this.pageIdx + 1;2654 this.matches = [];2655 this.viewport = viewport;2656 this.textDivs = [];2657 this.findController = findController;2658 this.textLayerRenderTask = null;2659 this.enhanceTextSelection = enhanceTextSelection;2660 this._bindMouse();2661 }2662 _createClass(TextLayerBuilder, [{2663 key: '_finishRendering',2664 value: function _finishRendering() {2665 this.renderingDone = true;2666 if (!this.enhanceTextSelection) {2667 var endOfContent = document.createElement('div');2668 endOfContent.className = 'endOfContent';2669 this.textLayerDiv.appendChild(endOfContent);2670 }2671 this.eventBus.dispatch('textlayerrendered', {2672 source: this,2673 pageNumber: this.pageNumber,2674 numTextDivs: this.textDivs.length2675 });2676 }2677 }, {2678 key: 'render',2679 value: function render() {2680 var _this = this;2681 var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;2682 if (!(this.textContent || this.textContentStream) || this.renderingDone) {2683 return;2684 }2685 this.cancel();2686 this.textDivs = [];2687 var textLayerFrag = document.createDocumentFragment();2688 this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({2689 textContent: this.textContent,2690 textContentStream: this.textContentStream,2691 container: textLayerFrag,2692 viewport: this.viewport,2693 textDivs: this.textDivs,2694 textContentItemsStr: this.textContentItemsStr,2695 timeout: timeout,2696 enhanceTextSelection: this.enhanceTextSelection2697 });2698 this.textLayerRenderTask.promise.then(function () {2699 _this.textLayerDiv.appendChild(textLayerFrag);2700 _this._finishRendering();2701 _this.updateMatches();2702 }, function (reason) {});2703 }2704 }, {2705 key: 'cancel',2706 value: function cancel() {2707 if (this.textLayerRenderTask) {2708 this.textLayerRenderTask.cancel();2709 this.textLayerRenderTask = null;2710 }2711 }2712 }, {2713 key: 'setTextContentStream',2714 value: function setTextContentStream(readableStream) {2715 this.cancel();2716 this.textContentStream = readableStream;2717 }2718 }, {2719 key: 'setTextContent',2720 value: function setTextContent(textContent) {2721 this.cancel();2722 this.textContent = textContent;2723 }2724 }, {2725 key: 'convertMatches',2726 value: function convertMatches(matches, matchesLength) {2727 var i = 0;2728 var iIndex = 0;2729 var textContentItemsStr = this.textContentItemsStr;2730 var end = textContentItemsStr.length - 1;2731 var queryLen = this.findController === null ? 0 : this.findController.state.query.length;2732 var ret = [];2733 if (!matches) {2734 return ret;2735 }2736 for (var m = 0, len = matches.length; m < len; m++) {2737 var matchIdx = matches[m];2738 while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {2739 iIndex += textContentItemsStr[i].length;2740 i++;2741 }2742 if (i === textContentItemsStr.length) {2743 console.error('Could not find a matching mapping');2744 }2745 var match = {2746 begin: {2747 divIdx: i,2748 offset: matchIdx - iIndex2749 }2750 };2751 if (matchesLength) {2752 matchIdx += matchesLength[m];2753 } else {2754 matchIdx += queryLen;2755 }2756 while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {2757 iIndex += textContentItemsStr[i].length;2758 i++;2759 }2760 match.end = {2761 divIdx: i,2762 offset: matchIdx - iIndex2763 };2764 ret.push(match);2765 }2766 return ret;2767 }2768 }, {2769 key: 'renderMatches',2770 value: function renderMatches(matches) {2771 if (matches.length === 0) {2772 return;2773 }2774 var textContentItemsStr = this.textContentItemsStr;2775 var textDivs = this.textDivs;2776 var prevEnd = null;2777 var pageIdx = this.pageIdx;2778 var isSelectedPage = this.findController === null ? false : pageIdx === this.findController.selected.pageIdx;2779 var selectedMatchIdx = this.findController === null ? -1 : this.findController.selected.matchIdx;2780 var highlightAll = this.findController === null ? false : this.findController.state.highlightAll;2781 var infinity = {2782 divIdx: -1,2783 offset: undefined2784 };2785 function beginText(begin, className) {2786 var divIdx = begin.divIdx;2787 textDivs[divIdx].textContent = '';2788 appendTextToDiv(divIdx, 0, begin.offset, className);2789 }2790 function appendTextToDiv(divIdx, fromOffset, toOffset, className) {2791 var div = textDivs[divIdx];2792 var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);2793 var node = document.createTextNode(content);2794 if (className) {2795 var span = document.createElement('span');2796 span.className = className;2797 span.appendChild(node);2798 div.appendChild(span);2799 return;2800 }2801 div.appendChild(node);2802 }2803 var i0 = selectedMatchIdx,2804 i1 = i0 + 1;2805 if (highlightAll) {2806 i0 = 0;2807 i1 = matches.length;2808 } else if (!isSelectedPage) {2809 return;2810 }2811 for (var i = i0; i < i1; i++) {2812 var match = matches[i];2813 var begin = match.begin;2814 var end = match.end;2815 var isSelected = isSelectedPage && i === selectedMatchIdx;2816 var highlightSuffix = isSelected ? ' selected' : '';2817 if (this.findController) {2818 this.findController.updateMatchPosition(pageIdx, i, textDivs, begin.divIdx);2819 }2820 if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {2821 if (prevEnd !== null) {2822 appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);2823 }2824 beginText(begin);2825 } else {2826 appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);2827 }2828 if (begin.divIdx === end.divIdx) {2829 appendTextToDiv(begin.divIdx, begin.offset, end.offset, 'highlight' + highlightSuffix);2830 } else {2831 appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, 'highlight begin' + highlightSuffix);2832 for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {2833 textDivs[n0].className = 'highlight middle' + highlightSuffix;2834 }2835 beginText(end, 'highlight end' + highlightSuffix);2836 }2837 prevEnd = end;2838 }2839 if (prevEnd) {2840 appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);2841 }2842 }2843 }, {2844 key: 'updateMatches',2845 value: function updateMatches() {2846 if (!this.renderingDone) {2847 return;2848 }2849 var matches = this.matches;2850 var textDivs = this.textDivs;2851 var textContentItemsStr = this.textContentItemsStr;2852 var clearedUntilDivIdx = -1;2853 for (var i = 0, len = matches.length; i < len; i++) {2854 var match = matches[i];2855 var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);2856 for (var n = begin, end = match.end.divIdx; n <= end; n++) {2857 var div = textDivs[n];2858 div.textContent = textContentItemsStr[n];2859 div.className = '';2860 }2861 clearedUntilDivIdx = match.end.divIdx + 1;2862 }2863 if (this.findController === null || !this.findController.active) {2864 return;2865 }2866 var pageMatches = void 0,2867 pageMatchesLength = void 0;2868 if (this.findController !== null) {2869 pageMatches = this.findController.pageMatches[this.pageIdx] || null;2870 pageMatchesLength = this.findController.pageMatchesLength ? this.findController.pageMatchesLength[this.pageIdx] || null : null;2871 }2872 this.matches = this.convertMatches(pageMatches, pageMatchesLength);2873 this.renderMatches(this.matches);2874 }2875 }, {2876 key: '_bindMouse',2877 value: function _bindMouse() {2878 var _this2 = this;2879 var div = this.textLayerDiv;2880 var expandDivsTimer = null;2881 div.addEventListener('mousedown', function (evt) {2882 if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {2883 _this2.textLayerRenderTask.expandTextDivs(true);2884 if (expandDivsTimer) {2885 clearTimeout(expandDivsTimer);2886 expandDivsTimer = null;2887 }2888 return;2889 }2890 var end = div.querySelector('.endOfContent');2891 if (!end) {2892 return;2893 }2894 var adjustTop = evt.target !== div;2895 adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue('-moz-user-select') !== 'none';2896 if (adjustTop) {2897 var divBounds = div.getBoundingClientRect();2898 var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);2899 end.style.top = (r * 100).toFixed(2) + '%';2900 }2901 end.classList.add('active');2902 });2903 div.addEventListener('mouseup', function () {2904 if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {2905 expandDivsTimer = setTimeout(function () {2906 if (_this2.textLayerRenderTask) {2907 _this2.textLayerRenderTask.expandTextDivs(false);2908 }2909 expandDivsTimer = null;2910 }, EXPAND_DIVS_TIMEOUT);2911 return;2912 }2913 var end = div.querySelector('.endOfContent');2914 if (!end) {2915 return;2916 }2917 end.style.top = '';2918 end.classList.remove('active');2919 });2920 }2921 }]);2922 return TextLayerBuilder;2923}();2924var DefaultTextLayerFactory = function () {2925 function DefaultTextLayerFactory() {2926 _classCallCheck(this, DefaultTextLayerFactory);2927 }2928 _createClass(DefaultTextLayerFactory, [{2929 key: 'createTextLayerBuilder',2930 value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {2931 var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;2932 return new TextLayerBuilder({2933 textLayerDiv: textLayerDiv,2934 pageIndex: pageIndex,2935 viewport: viewport,2936 enhanceTextSelection: enhanceTextSelection2937 });2938 }2939 }]);2940 return DefaultTextLayerFactory;2941}();2942exports.TextLayerBuilder = TextLayerBuilder;2943exports.DefaultTextLayerFactory = DefaultTextLayerFactory;2944/***/ }),2945/* 9 */2946/***/ (function(module, exports, __w_pdfjs_require__) {2947"use strict";2948var pdfjsLib = __w_pdfjs_require__(0);2949var pdfjsWebPDFViewer = __w_pdfjs_require__(10);2950var pdfjsWebPDFSinglePageViewer = __w_pdfjs_require__(11);2951var pdfjsWebPDFPageView = __w_pdfjs_require__(7);2952var pdfjsWebPDFLinkService = __w_pdfjs_require__(3);2953var pdfjsWebTextLayerBuilder = __w_pdfjs_require__(8);2954var pdfjsWebAnnotationLayerBuilder = __w_pdfjs_require__(6);2955var pdfjsWebPDFHistory = __w_pdfjs_require__(12);2956var pdfjsWebPDFFindController = __w_pdfjs_require__(13);2957var pdfjsWebUIUtils = __w_pdfjs_require__(1);2958var pdfjsWebDownloadManager = __w_pdfjs_require__(14);2959var pdfjsWebGenericL10n = __w_pdfjs_require__(15);2960var PDFJS = pdfjsLib.PDFJS;2961PDFJS.PDFViewer = pdfjsWebPDFViewer.PDFViewer;2962PDFJS.PDFSinglePageViewer = pdfjsWebPDFSinglePageViewer.PDFSinglePageViewer;2963PDFJS.PDFPageView = pdfjsWebPDFPageView.PDFPageView;2964PDFJS.PDFLinkService = pdfjsWebPDFLinkService.PDFLinkService;2965PDFJS.SimpleLinkService = pdfjsWebPDFLinkService.SimpleLinkService;2966PDFJS.TextLayerBuilder = pdfjsWebTextLayerBuilder.TextLayerBuilder;2967PDFJS.DefaultTextLayerFactory = pdfjsWebTextLayerBuilder.DefaultTextLayerFactory;2968PDFJS.AnnotationLayerBuilder = pdfjsWebAnnotationLayerBuilder.AnnotationLayerBuilder;2969PDFJS.DefaultAnnotationLayerFactory = pdfjsWebAnnotationLayerBuilder.DefaultAnnotationLayerFactory;2970PDFJS.PDFHistory = pdfjsWebPDFHistory.PDFHistory;2971PDFJS.PDFFindController = pdfjsWebPDFFindController.PDFFindController;2972PDFJS.EventBus = pdfjsWebUIUtils.EventBus;2973PDFJS.DownloadManager = pdfjsWebDownloadManager.DownloadManager;2974PDFJS.ProgressBar = pdfjsWebUIUtils.ProgressBar;2975PDFJS.GenericL10n = pdfjsWebGenericL10n.GenericL10n;2976PDFJS.NullL10n = pdfjsWebUIUtils.NullL10n;2977exports.PDFJS = PDFJS;2978/***/ }),2979/* 10 */2980/***/ (function(module, exports, __w_pdfjs_require__) {2981"use strict";2982Object.defineProperty(exports, "__esModule", {2983 value: true2984});2985exports.PDFViewer = undefined;2986var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();2987var _ui_utils = __w_pdfjs_require__(1);2988var _base_viewer = __w_pdfjs_require__(4);2989var _pdfjsLib = __w_pdfjs_require__(0);2990function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }2991function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }2992function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }2993var PDFViewer = function (_BaseViewer) {2994 _inherits(PDFViewer, _BaseViewer);2995 function PDFViewer() {2996 _classCallCheck(this, PDFViewer);2997 return _possibleConstructorReturn(this, (PDFViewer.__proto__ || Object.getPrototypeOf(PDFViewer)).apply(this, arguments));2998 }2999 _createClass(PDFViewer, [{3000 key: '_scrollIntoView',3001 value: function _scrollIntoView(_ref) {3002 var pageDiv = _ref.pageDiv,3003 _ref$pageSpot = _ref.pageSpot,3004 pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot;3005 (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);3006 }3007 }, {3008 key: '_getVisiblePages',3009 value: function _getVisiblePages() {3010 if (!this.isInPresentationMode) {3011 return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true);3012 }3013 var currentPage = this._pages[this._currentPageNumber - 1];3014 var visible = [{3015 id: currentPage.id,3016 view: currentPage3017 }];3018 return {3019 first: currentPage,3020 last: currentPage,3021 views: visible3022 };3023 }3024 }, {3025 key: 'update',3026 value: function update() {3027 var visible = this._getVisiblePages();3028 var visiblePages = visible.views,3029 numVisiblePages = visiblePages.length;3030 if (numVisiblePages === 0) {3031 return;3032 }3033 this._resizeBuffer(numVisiblePages);3034 this.renderingQueue.renderHighestPriority(visible);3035 var currentId = this._currentPageNumber;3036 var stillFullyVisible = false;3037 for (var i = 0; i < numVisiblePages; ++i) {3038 var page = visiblePages[i];3039 if (page.percent < 100) {3040 break;3041 }3042 if (page.id === currentId) {3043 stillFullyVisible = true;3044 break;3045 }3046 }3047 if (!stillFullyVisible) {3048 currentId = visiblePages[0].id;3049 }3050 if (!this.isInPresentationMode) {3051 this._setCurrentPageNumber(currentId);3052 }3053 this._updateLocation(visible.first);3054 this.eventBus.dispatch('updateviewarea', {3055 source: this,3056 location: this._location3057 });3058 }3059 }, {3060 key: '_setDocumentViewerElement',3061 get: function get() {3062 return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this.viewer);3063 }3064 }]);3065 return PDFViewer;3066}(_base_viewer.BaseViewer);3067exports.PDFViewer = PDFViewer;3068/***/ }),3069/* 11 */3070/***/ (function(module, exports, __w_pdfjs_require__) {3071"use strict";3072Object.defineProperty(exports, "__esModule", {3073 value: true3074});3075exports.PDFSinglePageViewer = undefined;3076var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();3077var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };3078var _base_viewer = __w_pdfjs_require__(4);3079var _ui_utils = __w_pdfjs_require__(1);3080var _pdfjsLib = __w_pdfjs_require__(0);3081function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }3082function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }3083function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }3084var PDFSinglePageViewer = function (_BaseViewer) {3085 _inherits(PDFSinglePageViewer, _BaseViewer);3086 function PDFSinglePageViewer(options) {3087 _classCallCheck(this, PDFSinglePageViewer);3088 var _this = _possibleConstructorReturn(this, (PDFSinglePageViewer.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer)).call(this, options));3089 _this.eventBus.on('pagesinit', function (evt) {3090 _this._ensurePageViewVisible();3091 });3092 return _this;3093 }3094 _createClass(PDFSinglePageViewer, [{3095 key: '_resetView',3096 value: function _resetView() {3097 _get(PDFSinglePageViewer.prototype.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer.prototype), '_resetView', this).call(this);3098 this._previousPageNumber = 1;3099 this._shadowViewer = document.createDocumentFragment();3100 }3101 }, {3102 key: '_ensurePageViewVisible',3103 value: function _ensurePageViewVisible() {3104 var pageView = this._pages[this._currentPageNumber - 1];3105 var previousPageView = this._pages[this._previousPageNumber - 1];3106 var viewerNodes = this.viewer.childNodes;3107 switch (viewerNodes.length) {3108 case 0:3109 this.viewer.appendChild(pageView.div);3110 break;3111 case 1:3112 if (viewerNodes[0] !== previousPageView.div) {3113 throw new Error('_ensurePageViewVisible: Unexpected previously visible page.');3114 }3115 if (pageView === previousPageView) {3116 break;3117 }3118 this._shadowViewer.appendChild(previousPageView.div);3119 this.viewer.appendChild(pageView.div);3120 this.container.scrollTop = 0;3121 break;3122 default:3123 throw new Error('_ensurePageViewVisible: Only one page should be visible at a time.');3124 }3125 this._previousPageNumber = this._currentPageNumber;3126 }3127 }, {3128 key: '_scrollUpdate',3129 value: function _scrollUpdate() {3130 if (this._updateScrollDown) {3131 this._updateScrollDown();3132 }3133 _get(PDFSinglePageViewer.prototype.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer.prototype), '_scrollUpdate', this).call(this);3134 }3135 }, {3136 key: '_scrollIntoView',3137 value: function _scrollIntoView(_ref) {3138 var _this2 = this;3139 var pageDiv = _ref.pageDiv,3140 _ref$pageSpot = _ref.pageSpot,3141 pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot,3142 _ref$pageNumber = _ref.pageNumber,3143 pageNumber = _ref$pageNumber === undefined ? null : _ref$pageNumber;3144 if (pageNumber) {3145 this._setCurrentPageNumber(pageNumber);3146 }3147 var scrolledDown = this._currentPageNumber >= this._previousPageNumber;3148 var previousLocation = this._location;3149 this._ensurePageViewVisible();3150 (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);3151 this._updateScrollDown = function () {3152 _this2.scroll.down = scrolledDown;3153 delete _this2._updateScrollDown;3154 };3155 setTimeout(function () {3156 if (_this2._location === previousLocation) {3157 if (_this2._updateScrollDown) {3158 _this2._updateScrollDown();3159 }3160 _this2.update();3161 }3162 }, 0);3163 }3164 }, {3165 key: '_getVisiblePages',3166 value: function _getVisiblePages() {3167 if (!this.pagesCount) {3168 return { views: [] };3169 }3170 var pageView = this._pages[this._currentPageNumber - 1];3171 var element = pageView.div;3172 var view = {3173 id: pageView.id,3174 x: element.offsetLeft + element.clientLeft,3175 y: element.offsetTop + element.clientTop,3176 view: pageView3177 };3178 return {3179 first: view,3180 last: view,3181 views: [view]3182 };3183 }3184 }, {3185 key: 'update',3186 value: function update() {3187 var visible = this._getVisiblePages();3188 var visiblePages = visible.views,3189 numVisiblePages = visiblePages.length;3190 if (numVisiblePages === 0) {3191 return;3192 }3193 this._resizeBuffer(numVisiblePages);3194 this.renderingQueue.renderHighestPriority(visible);3195 this._updateLocation(visible.first);3196 this.eventBus.dispatch('updateviewarea', {3197 source: this,3198 location: this._location3199 });3200 }3201 }, {3202 key: '_setDocumentViewerElement',3203 get: function get() {3204 return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this._shadowViewer);3205 }3206 }]);3207 return PDFSinglePageViewer;3208}(_base_viewer.BaseViewer);3209exports.PDFSinglePageViewer = PDFSinglePageViewer;3210/***/ }),3211/* 12 */3212/***/ (function(module, exports, __w_pdfjs_require__) {3213"use strict";3214Object.defineProperty(exports, "__esModule", {3215 value: true3216});3217exports.isDestArraysEqual = exports.isDestHashesEqual = exports.PDFHistory = undefined;3218var _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; };3219var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();3220var _ui_utils = __w_pdfjs_require__(1);3221var _dom_events = __w_pdfjs_require__(2);3222function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }3223var HASH_CHANGE_TIMEOUT = 1000;3224var POSITION_UPDATED_THRESHOLD = 50;3225var UPDATE_VIEWAREA_TIMEOUT = 1000;3226function getCurrentHash() {3227 return document.location.hash;3228}3229function parseCurrentHash(linkService) {3230 var hash = unescape(getCurrentHash()).substring(1);3231 var params = (0, _ui_utils.parseQueryString)(hash);3232 var page = params.page | 0;3233 if (!(Number.isInteger(page) && page > 0 && page <= linkService.pagesCount)) {3234 page = null;3235 }3236 return {3237 hash: hash,3238 page: page,3239 rotation: linkService.rotation3240 };3241}3242var PDFHistory = function () {3243 function PDFHistory(_ref) {3244 var _this = this;3245 var linkService = _ref.linkService,3246 eventBus = _ref.eventBus;3247 _classCallCheck(this, PDFHistory);3248 this.linkService = linkService;3249 this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();3250 this.initialized = false;3251 this.initialBookmark = null;3252 this.initialRotation = null;3253 this._boundEvents = Object.create(null);3254 this._isViewerInPresentationMode = false;3255 this._isPagesLoaded = false;3256 this.eventBus.on('presentationmodechanged', function (evt) {3257 _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;3258 });3259 this.eventBus.on('pagesloaded', function (evt) {3260 _this._isPagesLoaded = !!evt.pagesCount;3261 });3262 }3263 _createClass(PDFHistory, [{3264 key: 'initialize',3265 value: function initialize(fingerprint) {3266 var resetHistory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;3267 if (!fingerprint || typeof fingerprint !== 'string') {3268 console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');3269 return;3270 }3271 var reInitialized = this.initialized && this.fingerprint !== fingerprint;3272 this.fingerprint = fingerprint;3273 if (!this.initialized) {3274 this._bindEvents();3275 }3276 var state = window.history.state;3277 this.initialized = true;3278 this.initialBookmark = null;3279 this.initialRotation = null;3280 this._popStateInProgress = false;3281 this._blockHashChange = 0;3282 this._currentHash = getCurrentHash();3283 this._numPositionUpdates = 0;3284 this._uid = this._maxUid = 0;3285 this._destination = null;3286 this._position = null;3287 if (!this._isValidState(state) || resetHistory) {3288 var _parseCurrentHash = parseCurrentHash(this.linkService),3289 hash = _parseCurrentHash.hash,3290 page = _parseCurrentHash.page,3291 rotation = _parseCurrentHash.rotation;3292 if (!hash || reInitialized || resetHistory) {3293 this._pushOrReplaceState(null, true);3294 return;3295 }3296 this._pushOrReplaceState({3297 hash: hash,3298 page: page,3299 rotation: rotation3300 }, true);3301 return;3302 }3303 var destination = state.destination;3304 this._updateInternalState(destination, state.uid, true);3305 if (destination.rotation !== undefined) {3306 this.initialRotation = destination.rotation;3307 }3308 if (destination.dest) {3309 this.initialBookmark = JSON.stringify(destination.dest);3310 this._destination.page = null;3311 } else if (destination.hash) {3312 this.initialBookmark = destination.hash;3313 } else if (destination.page) {3314 this.initialBookmark = 'page=' + destination.page;3315 }3316 }3317 }, {3318 key: 'push',3319 value: function push(_ref2) {3320 var _this2 = this;3321 var namedDest = _ref2.namedDest,3322 explicitDest = _ref2.explicitDest,3323 pageNumber = _ref2.pageNumber;3324 if (!this.initialized) {3325 return;3326 }3327 if (namedDest && typeof namedDest !== 'string' || !(explicitDest instanceof Array) || !(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {3328 console.error('PDFHistory.push: Invalid parameters.');3329 return;3330 }3331 var hash = namedDest || JSON.stringify(explicitDest);3332 if (!hash) {3333 return;3334 }3335 var forceReplace = false;3336 if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {3337 if (this._destination.page) {3338 return;3339 }3340 forceReplace = true;3341 }3342 if (this._popStateInProgress && !forceReplace) {3343 return;3344 }3345 this._pushOrReplaceState({3346 dest: explicitDest,3347 hash: hash,3348 page: pageNumber,3349 rotation: this.linkService.rotation3350 }, forceReplace);3351 if (!this._popStateInProgress) {3352 this._popStateInProgress = true;3353 Promise.resolve().then(function () {3354 _this2._popStateInProgress = false;3355 });3356 }3357 }3358 }, {3359 key: 'pushCurrentPosition',3360 value: function pushCurrentPosition() {3361 if (!this.initialized || this._popStateInProgress) {3362 return;3363 }3364 this._tryPushCurrentPosition();3365 }3366 }, {3367 key: 'back',3368 value: function back() {3369 if (!this.initialized || this._popStateInProgress) {3370 return;3371 }3372 var state = window.history.state;3373 if (this._isValidState(state) && state.uid > 0) {3374 window.history.back();3375 }3376 }3377 }, {3378 key: 'forward',3379 value: function forward() {3380 if (!this.initialized || this._popStateInProgress) {3381 return;3382 }3383 var state = window.history.state;3384 if (this._isValidState(state) && state.uid < this._maxUid) {3385 window.history.forward();3386 }3387 }3388 }, {3389 key: '_pushOrReplaceState',3390 value: function _pushOrReplaceState(destination) {3391 var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;3392 var shouldReplace = forceReplace || !this._destination;3393 var newState = {3394 fingerprint: this.fingerprint,3395 uid: shouldReplace ? this._uid : this._uid + 1,3396 destination: destination3397 };3398 this._updateInternalState(destination, newState.uid);3399 if (shouldReplace) {3400 window.history.replaceState(newState, '', document.URL);3401 } else {3402 this._maxUid = this._uid;3403 window.history.pushState(newState, '', document.URL);3404 }3405 }3406 }, {3407 key: '_tryPushCurrentPosition',3408 value: function _tryPushCurrentPosition() {3409 var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;3410 if (!this._position) {3411 return;3412 }3413 var position = this._position;3414 if (temporary) {3415 position = (0, _ui_utils.cloneObj)(this._position);3416 position.temporary = true;3417 }3418 if (!this._destination) {3419 this._pushOrReplaceState(position);3420 return;3421 }3422 if (this._destination.temporary) {3423 this._pushOrReplaceState(position, true);3424 return;3425 }3426 if (this._destination.hash === position.hash) {3427 return;3428 }3429 if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {3430 return;3431 }3432 var forceReplace = false;3433 if (this._destination.page === position.first || this._destination.page === position.page) {3434 if (this._destination.dest || !this._destination.first) {3435 return;3436 }3437 forceReplace = true;3438 }3439 this._pushOrReplaceState(position, forceReplace);3440 }3441 }, {3442 key: '_isValidState',3443 value: function _isValidState(state) {3444 if (!state) {3445 return false;3446 }3447 if (state.fingerprint !== this.fingerprint) {3448 return false;3449 }3450 if (!Number.isInteger(state.uid) || state.uid < 0) {3451 return false;3452 }3453 if (state.destination === null || _typeof(state.destination) !== 'object') {3454 return false;3455 }3456 return true;3457 }3458 }, {3459 key: '_updateInternalState',3460 value: function _updateInternalState(destination, uid) {3461 var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;3462 if (this._updateViewareaTimeout) {3463 clearTimeout(this._updateViewareaTimeout);3464 this._updateViewareaTimeout = null;3465 }3466 if (removeTemporary && destination && destination.temporary) {3467 delete destination.temporary;3468 }3469 this._destination = destination;3470 this._uid = uid;3471 this._numPositionUpdates = 0;3472 }3473 }, {3474 key: '_updateViewarea',3475 value: function _updateViewarea(_ref3) {3476 var _this3 = this;3477 var location = _ref3.location;3478 if (this._updateViewareaTimeout) {3479 clearTimeout(this._updateViewareaTimeout);3480 this._updateViewareaTimeout = null;3481 }3482 this._position = {3483 hash: this._isViewerInPresentationMode ? 'page=' + location.pageNumber : location.pdfOpenParams.substring(1),3484 page: this.linkService.page,3485 first: location.pageNumber,3486 rotation: location.rotation3487 };3488 if (this._popStateInProgress) {3489 return;3490 }3491 if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {3492 this._numPositionUpdates++;3493 }3494 if (UPDATE_VIEWAREA_TIMEOUT > 0) {3495 this._updateViewareaTimeout = setTimeout(function () {3496 if (!_this3._popStateInProgress) {3497 _this3._tryPushCurrentPosition(true);3498 }3499 _this3._updateViewareaTimeout = null;3500 }, UPDATE_VIEWAREA_TIMEOUT);3501 }3502 }3503 }, {3504 key: '_popState',3505 value: function _popState(_ref4) {3506 var _this4 = this;3507 var state = _ref4.state;3508 var newHash = getCurrentHash(),3509 hashChanged = this._currentHash !== newHash;3510 this._currentHash = newHash;3511 if (!state || false) {3512 this._uid++;3513 var _parseCurrentHash2 = parseCurrentHash(this.linkService),3514 hash = _parseCurrentHash2.hash,3515 page = _parseCurrentHash2.page,3516 rotation = _parseCurrentHash2.rotation;3517 this._pushOrReplaceState({3518 hash: hash,3519 page: page,3520 rotation: rotation3521 }, true);3522 return;3523 }3524 if (!this._isValidState(state)) {3525 return;3526 }3527 this._popStateInProgress = true;3528 if (hashChanged) {3529 this._blockHashChange++;3530 (0, _ui_utils.waitOnEventOrTimeout)({3531 target: window,3532 name: 'hashchange',3533 delay: HASH_CHANGE_TIMEOUT3534 }).then(function () {3535 _this4._blockHashChange--;3536 });3537 }3538 var destination = state.destination;3539 this._updateInternalState(destination, state.uid, true);3540 if ((0, _ui_utils.isValidRotation)(destination.rotation)) {3541 this.linkService.rotation = destination.rotation;3542 }3543 if (destination.dest) {3544 this.linkService.navigateTo(destination.dest);3545 } else if (destination.hash) {3546 this.linkService.setHash(destination.hash);3547 } else if (destination.page) {3548 this.linkService.page = destination.page;3549 }3550 Promise.resolve().then(function () {3551 _this4._popStateInProgress = false;3552 });3553 }3554 }, {3555 key: '_bindEvents',3556 value: function _bindEvents() {3557 var _this5 = this;3558 var _boundEvents = this._boundEvents,3559 eventBus = this.eventBus;3560 _boundEvents.updateViewarea = this._updateViewarea.bind(this);3561 _boundEvents.popState = this._popState.bind(this);3562 _boundEvents.pageHide = function (evt) {3563 if (!_this5._destination) {3564 _this5._tryPushCurrentPosition();3565 }3566 };3567 eventBus.on('updateviewarea', _boundEvents.updateViewarea);3568 window.addEventListener('popstate', _boundEvents.popState);3569 window.addEventListener('pagehide', _boundEvents.pageHide);3570 }3571 }, {3572 key: 'popStateInProgress',3573 get: function get() {3574 return this.initialized && (this._popStateInProgress || this._blockHashChange > 0);3575 }3576 }]);3577 return PDFHistory;3578}();3579function isDestHashesEqual(destHash, pushHash) {3580 if (typeof destHash !== 'string' || typeof pushHash !== 'string') {3581 return false;3582 }3583 if (destHash === pushHash) {3584 return true;3585 }3586 var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),3587 nameddest = _parseQueryString.nameddest;3588 if (nameddest === pushHash) {3589 return true;3590 }3591 return false;3592}3593function isDestArraysEqual(firstDest, secondDest) {3594 function isEntryEqual(first, second) {3595 if ((typeof first === 'undefined' ? 'undefined' : _typeof(first)) !== (typeof second === 'undefined' ? 'undefined' : _typeof(second))) {3596 return false;3597 }3598 if (first instanceof Array || second instanceof Array) {3599 return false;3600 }3601 if (first !== null && (typeof first === 'undefined' ? 'undefined' : _typeof(first)) === 'object' && second !== null) {3602 if (Object.keys(first).length !== Object.keys(second).length) {3603 return false;3604 }3605 for (var key in first) {3606 if (!isEntryEqual(first[key], second[key])) {3607 return false;3608 }3609 }3610 return true;3611 }3612 return first === second || Number.isNaN(first) && Number.isNaN(second);3613 }3614 if (!(firstDest instanceof Array && secondDest instanceof Array)) {3615 return false;3616 }3617 if (firstDest.length !== secondDest.length) {3618 return false;3619 }3620 for (var i = 0, ii = firstDest.length; i < ii; i++) {3621 if (!isEntryEqual(firstDest[i], secondDest[i])) {3622 return false;3623 }3624 }3625 return true;3626}3627exports.PDFHistory = PDFHistory;3628exports.isDestHashesEqual = isDestHashesEqual;3629exports.isDestArraysEqual = isDestArraysEqual;3630/***/ }),3631/* 13 */3632/***/ (function(module, exports, __w_pdfjs_require__) {3633"use strict";3634Object.defineProperty(exports, "__esModule", {3635 value: true3636});3637exports.PDFFindController = exports.FindState = undefined;3638var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();3639var _pdfjsLib = __w_pdfjs_require__(0);3640var _ui_utils = __w_pdfjs_require__(1);3641function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }3642var FindState = {3643 FOUND: 0,3644 NOT_FOUND: 1,3645 WRAPPED: 2,3646 PENDING: 33647};3648var FIND_SCROLL_OFFSET_TOP = -50;3649var FIND_SCROLL_OFFSET_LEFT = -400;3650var FIND_TIMEOUT = 250;3651var CHARACTERS_TO_NORMALIZE = {3652 '\u2018': '\'',3653 '\u2019': '\'',3654 '\u201A': '\'',3655 '\u201B': '\'',3656 '\u201C': '"',3657 '\u201D': '"',3658 '\u201E': '"',3659 '\u201F': '"',3660 '\xBC': '1/4',3661 '\xBD': '1/2',3662 '\xBE': '3/4'3663};3664var PDFFindController = function () {3665 function PDFFindController(_ref) {3666 var pdfViewer = _ref.pdfViewer;3667 _classCallCheck(this, PDFFindController);3668 this.pdfViewer = pdfViewer;3669 this.onUpdateResultsCount = null;3670 this.onUpdateState = null;3671 this.reset();3672 var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');3673 this.normalizationRegex = new RegExp('[' + replace + ']', 'g');3674 }3675 _createClass(PDFFindController, [{3676 key: 'reset',3677 value: function reset() {3678 var _this = this;3679 this.startedTextExtraction = false;3680 this.extractTextPromises = [];3681 this.pendingFindMatches = Object.create(null);3682 this.active = false;3683 this.pageContents = [];3684 this.pageMatches = [];3685 this.pageMatchesLength = null;3686 this.matchCount = 0;3687 this.selected = {3688 pageIdx: -1,3689 matchIdx: -13690 };3691 this.offset = {3692 pageIdx: null,3693 matchIdx: null3694 };3695 this.pagesToSearch = null;3696 this.resumePageIdx = null;3697 this.state = null;3698 this.dirtyMatch = false;3699 this.findTimeout = null;3700 this._firstPagePromise = new Promise(function (resolve) {3701 _this.resolveFirstPage = resolve;3702 });3703 }3704 }, {3705 key: 'normalize',3706 value: function normalize(text) {3707 return text.replace(this.normalizationRegex, function (ch) {3708 return CHARACTERS_TO_NORMALIZE[ch];3709 });3710 }3711 }, {3712 key: '_prepareMatches',3713 value: function _prepareMatches(matchesWithLength, matches, matchesLength) {3714 function isSubTerm(matchesWithLength, currentIndex) {3715 var currentElem = matchesWithLength[currentIndex];3716 var nextElem = matchesWithLength[currentIndex + 1];3717 if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {3718 currentElem.skipped = true;3719 return true;3720 }3721 for (var i = currentIndex - 1; i >= 0; i--) {3722 var prevElem = matchesWithLength[i];3723 if (prevElem.skipped) {3724 continue;3725 }3726 if (prevElem.match + prevElem.matchLength < currentElem.match) {3727 break;3728 }3729 if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {3730 currentElem.skipped = true;3731 return true;3732 }3733 }3734 return false;3735 }3736 matchesWithLength.sort(function (a, b) {3737 return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;3738 });3739 for (var i = 0, len = matchesWithLength.length; i < len; i++) {3740 if (isSubTerm(matchesWithLength, i)) {3741 continue;3742 }3743 matches.push(matchesWithLength[i].match);3744 matchesLength.push(matchesWithLength[i].matchLength);3745 }3746 }3747 }, {3748 key: 'calcFindPhraseMatch',3749 value: function calcFindPhraseMatch(query, pageIndex, pageContent) {3750 var matches = [];3751 var queryLen = query.length;3752 var matchIdx = -queryLen;3753 while (true) {3754 matchIdx = pageContent.indexOf(query, matchIdx + queryLen);3755 if (matchIdx === -1) {3756 break;3757 }3758 matches.push(matchIdx);3759 }3760 this.pageMatches[pageIndex] = matches;3761 }3762 }, {3763 key: 'calcFindWordMatch',3764 value: function calcFindWordMatch(query, pageIndex, pageContent) {3765 var matchesWithLength = [];3766 var queryArray = query.match(/\S+/g);3767 for (var i = 0, len = queryArray.length; i < len; i++) {3768 var subquery = queryArray[i];3769 var subqueryLen = subquery.length;3770 var matchIdx = -subqueryLen;3771 while (true) {3772 matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);3773 if (matchIdx === -1) {3774 break;3775 }3776 matchesWithLength.push({3777 match: matchIdx,3778 matchLength: subqueryLen,3779 skipped: false3780 });3781 }3782 }3783 if (!this.pageMatchesLength) {3784 this.pageMatchesLength = [];3785 }3786 this.pageMatchesLength[pageIndex] = [];3787 this.pageMatches[pageIndex] = [];3788 this._prepareMatches(matchesWithLength, this.pageMatches[pageIndex], this.pageMatchesLength[pageIndex]);3789 }3790 }, {3791 key: 'calcFindMatch',3792 value: function calcFindMatch(pageIndex) {3793 var pageContent = this.normalize(this.pageContents[pageIndex]);3794 var query = this.normalize(this.state.query);3795 var caseSensitive = this.state.caseSensitive;3796 var phraseSearch = this.state.phraseSearch;3797 var queryLen = query.length;3798 if (queryLen === 0) {3799 return;3800 }3801 if (!caseSensitive) {3802 pageContent = pageContent.toLowerCase();3803 query = query.toLowerCase();3804 }3805 if (phraseSearch) {3806 this.calcFindPhraseMatch(query, pageIndex, pageContent);3807 } else {3808 this.calcFindWordMatch(query, pageIndex, pageContent);3809 }3810 this.updatePage(pageIndex);3811 if (this.resumePageIdx === pageIndex) {3812 this.resumePageIdx = null;3813 this.nextPageMatch();3814 }3815 if (this.pageMatches[pageIndex].length > 0) {3816 this.matchCount += this.pageMatches[pageIndex].length;3817 this.updateUIResultsCount();3818 }3819 }3820 }, {3821 key: 'extractText',3822 value: function extractText() {3823 var _this2 = this;3824 if (this.startedTextExtraction) {3825 return;3826 }3827 this.startedTextExtraction = true;3828 this.pageContents.length = 0;3829 var promise = Promise.resolve();3830 var _loop = function _loop(i, ii) {3831 var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();3832 _this2.extractTextPromises[i] = extractTextCapability.promise;3833 promise = promise.then(function () {3834 return _this2.pdfViewer.getPageTextContent(i).then(function (textContent) {3835 var textItems = textContent.items;3836 var strBuf = [];3837 for (var j = 0, jj = textItems.length; j < jj; j++) {3838 strBuf.push(textItems[j].str);3839 }3840 _this2.pageContents[i] = strBuf.join('');3841 extractTextCapability.resolve(i);3842 }, function (reason) {3843 console.error('Unable to get page ' + (i + 1) + ' text content', reason);3844 _this2.pageContents[i] = '';3845 extractTextCapability.resolve(i);3846 });3847 });3848 };3849 for (var i = 0, ii = this.pdfViewer.pagesCount; i < ii; i++) {3850 _loop(i, ii);3851 }3852 }3853 }, {3854 key: 'executeCommand',3855 value: function executeCommand(cmd, state) {3856 var _this3 = this;3857 if (this.state === null || cmd !== 'findagain') {3858 this.dirtyMatch = true;3859 }3860 this.state = state;3861 this.updateUIState(FindState.PENDING);3862 this._firstPagePromise.then(function () {3863 _this3.extractText();3864 clearTimeout(_this3.findTimeout);3865 if (cmd === 'find') {3866 _this3.findTimeout = setTimeout(_this3.nextMatch.bind(_this3), FIND_TIMEOUT);3867 } else {3868 _this3.nextMatch();3869 }3870 });3871 }3872 }, {3873 key: 'updatePage',3874 value: function updatePage(index) {3875 if (this.selected.pageIdx === index) {3876 this.pdfViewer.currentPageNumber = index + 1;3877 }3878 var page = this.pdfViewer.getPageView(index);3879 if (page.textLayer) {3880 page.textLayer.updateMatches();3881 }3882 }3883 }, {3884 key: 'nextMatch',3885 value: function nextMatch() {3886 var _this4 = this;3887 var previous = this.state.findPrevious;3888 var currentPageIndex = this.pdfViewer.currentPageNumber - 1;3889 var numPages = this.pdfViewer.pagesCount;3890 this.active = true;3891 if (this.dirtyMatch) {3892 this.dirtyMatch = false;3893 this.selected.pageIdx = this.selected.matchIdx = -1;3894 this.offset.pageIdx = currentPageIndex;3895 this.offset.matchIdx = null;3896 this.hadMatch = false;3897 this.resumePageIdx = null;3898 this.pageMatches = [];3899 this.matchCount = 0;3900 this.pageMatchesLength = null;3901 for (var i = 0; i < numPages; i++) {3902 this.updatePage(i);3903 if (!(i in this.pendingFindMatches)) {3904 this.pendingFindMatches[i] = true;3905 this.extractTextPromises[i].then(function (pageIdx) {3906 delete _this4.pendingFindMatches[pageIdx];3907 _this4.calcFindMatch(pageIdx);3908 });3909 }3910 }3911 }3912 if (this.state.query === '') {3913 this.updateUIState(FindState.FOUND);3914 return;3915 }3916 if (this.resumePageIdx) {3917 return;3918 }3919 var offset = this.offset;3920 this.pagesToSearch = numPages;3921 if (offset.matchIdx !== null) {3922 var numPageMatches = this.pageMatches[offset.pageIdx].length;3923 if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {3924 this.hadMatch = true;3925 offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;3926 this.updateMatch(true);3927 return;3928 }3929 this.advanceOffsetPage(previous);3930 }3931 this.nextPageMatch();3932 }3933 }, {3934 key: 'matchesReady',3935 value: function matchesReady(matches) {3936 var offset = this.offset;3937 var numMatches = matches.length;3938 var previous = this.state.findPrevious;3939 if (numMatches) {3940 this.hadMatch = true;3941 offset.matchIdx = previous ? numMatches - 1 : 0;3942 this.updateMatch(true);3943 return true;3944 }3945 this.advanceOffsetPage(previous);3946 if (offset.wrapped) {3947 offset.matchIdx = null;3948 if (this.pagesToSearch < 0) {3949 this.updateMatch(false);3950 return true;3951 }3952 }3953 return false;3954 }3955 }, {3956 key: 'updateMatchPosition',3957 value: function updateMatchPosition(pageIndex, matchIndex, elements, beginIdx) {3958 if (this.selected.matchIdx === matchIndex && this.selected.pageIdx === pageIndex) {3959 var spot = {3960 top: FIND_SCROLL_OFFSET_TOP,3961 left: FIND_SCROLL_OFFSET_LEFT3962 };3963 (0, _ui_utils.scrollIntoView)(elements[beginIdx], spot, true);3964 }3965 }3966 }, {3967 key: 'nextPageMatch',3968 value: function nextPageMatch() {3969 if (this.resumePageIdx !== null) {3970 console.error('There can only be one pending page.');3971 }3972 var matches = null;3973 do {3974 var pageIdx = this.offset.pageIdx;3975 matches = this.pageMatches[pageIdx];3976 if (!matches) {3977 this.resumePageIdx = pageIdx;3978 break;3979 }3980 } while (!this.matchesReady(matches));3981 }3982 }, {3983 key: 'advanceOffsetPage',3984 value: function advanceOffsetPage(previous) {3985 var offset = this.offset;3986 var numPages = this.extractTextPromises.length;3987 offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;3988 offset.matchIdx = null;3989 this.pagesToSearch--;3990 if (offset.pageIdx >= numPages || offset.pageIdx < 0) {3991 offset.pageIdx = previous ? numPages - 1 : 0;3992 offset.wrapped = true;3993 }3994 }3995 }, {3996 key: 'updateMatch',3997 value: function updateMatch() {3998 var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;3999 var state = FindState.NOT_FOUND;4000 var wrapped = this.offset.wrapped;4001 this.offset.wrapped = false;4002 if (found) {4003 var previousPage = this.selected.pageIdx;4004 this.selected.pageIdx = this.offset.pageIdx;4005 this.selected.matchIdx = this.offset.matchIdx;4006 state = wrapped ? FindState.WRAPPED : FindState.FOUND;4007 if (previousPage !== -1 && previousPage !== this.selected.pageIdx) {4008 this.updatePage(previousPage);4009 }4010 }4011 this.updateUIState(state, this.state.findPrevious);4012 if (this.selected.pageIdx !== -1) {4013 this.updatePage(this.selected.pageIdx);4014 }4015 }4016 }, {4017 key: 'updateUIResultsCount',4018 value: function updateUIResultsCount() {4019 if (this.onUpdateResultsCount) {4020 this.onUpdateResultsCount(this.matchCount);4021 }4022 }4023 }, {4024 key: 'updateUIState',4025 value: function updateUIState(state, previous) {4026 if (this.onUpdateState) {4027 this.onUpdateState(state, previous, this.matchCount);4028 }4029 }4030 }]);4031 return PDFFindController;4032}();4033exports.FindState = FindState;4034exports.PDFFindController = PDFFindController;4035/***/ }),4036/* 14 */4037/***/ (function(module, exports, __w_pdfjs_require__) {4038"use strict";4039Object.defineProperty(exports, "__esModule", {4040 value: true4041});4042exports.DownloadManager = undefined;4043var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();4044var _pdfjsLib = __w_pdfjs_require__(0);4045function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }4046;4047function _download(blobUrl, filename) {4048 var a = document.createElement('a');4049 if (a.click) {4050 a.href = blobUrl;4051 a.target = '_parent';4052 if ('download' in a) {4053 a.download = filename;4054 }4055 (document.body || document.documentElement).appendChild(a);4056 a.click();4057 a.parentNode.removeChild(a);4058 } else {4059 if (window.top === window && blobUrl.split('#')[0] === window.location.href.split('#')[0]) {4060 var padCharacter = blobUrl.indexOf('?') === -1 ? '?' : '&';4061 blobUrl = blobUrl.replace(/#|$/, padCharacter + '$&');4062 }4063 window.open(blobUrl, '_parent');4064 }4065}4066var DownloadManager = function () {4067 function DownloadManager() {4068 _classCallCheck(this, DownloadManager);4069 }4070 _createClass(DownloadManager, [{4071 key: 'downloadUrl',4072 value: function downloadUrl(url, filename) {4073 if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {4074 return;4075 }4076 _download(url + '#pdfjs.action=download', filename);4077 }4078 }, {4079 key: 'downloadData',4080 value: function downloadData(data, filename, contentType) {4081 if (navigator.msSaveBlob) {4082 return navigator.msSaveBlob(new Blob([data], { type: contentType }), filename);4083 }4084 var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, _pdfjsLib.PDFJS.disableCreateObjectURL);4085 _download(blobUrl, filename);4086 }4087 }, {4088 key: 'download',4089 value: function download(blob, url, filename) {4090 if (navigator.msSaveBlob) {4091 if (!navigator.msSaveBlob(blob, filename)) {4092 this.downloadUrl(url, filename);4093 }4094 return;4095 }4096 if (_pdfjsLib.PDFJS.disableCreateObjectURL) {4097 this.downloadUrl(url, filename);4098 return;4099 }4100 var blobUrl = URL.createObjectURL(blob);4101 _download(blobUrl, filename);4102 }4103 }]);4104 return DownloadManager;4105}();4106exports.DownloadManager = DownloadManager;4107/***/ }),4108/* 15 */4109/***/ (function(module, exports, __w_pdfjs_require__) {4110"use strict";4111Object.defineProperty(exports, "__esModule", {4112 value: true4113});4114exports.GenericL10n = undefined;4115var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();4116__w_pdfjs_require__(16);4117function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }4118var webL10n = document.webL10n;4119var GenericL10n = function () {4120 function GenericL10n(lang) {4121 _classCallCheck(this, GenericL10n);4122 this._lang = lang;4123 this._ready = new Promise(function (resolve, reject) {4124 webL10n.setLanguage(lang, function () {4125 resolve(webL10n);4126 });4127 });4128 }4129 _createClass(GenericL10n, [{4130 key: 'getDirection',...

Full Screen

Full Screen

pdf.js

Source:pdf.js Github

copy

Full Screen

...32 // webpackBootstrap33 /******/ // The module cache34 /******/ var installedModules = {}; // The require function35 /******/36 /******/ /******/ function __w_pdfjs_require__(moduleId) {37 /******/38 /******/ // Check if module is in cache39 /******/ if (installedModules[moduleId]) {40 /******/ return installedModules[moduleId].exports;41 /******/42 } // Create a new module (and put it into the cache)43 /******/ /******/ var module = (installedModules[moduleId] = {44 /******/ i: moduleId,45 /******/ l: false,46 /******/ exports: {}47 /******/48 }); // Execute the module function49 /******/50 /******/ /******/ modules[moduleId].call(51 module.exports,52 module,53 module.exports,54 __w_pdfjs_require__55 ); // Flag the module as loaded56 /******/57 /******/ /******/ module.l = true; // Return the exports of the module58 /******/59 /******/ /******/ return module.exports;60 /******/61 } // expose the modules object (__webpack_modules__)62 /******/63 /******/64 /******/ /******/ __w_pdfjs_require__.m = modules; // expose the module cache65 /******/66 /******/ /******/ __w_pdfjs_require__.c = installedModules; // define getter function for harmony exports67 /******/68 /******/ /******/ __w_pdfjs_require__.d = function(exports, name, getter) {69 /******/ if (!__w_pdfjs_require__.o(exports, name)) {70 /******/ Object.defineProperty(exports, name, {71 enumerable: true,72 get: getter73 });74 /******/75 }76 /******/77 }; // define __esModule on exports78 /******/79 /******/ /******/ __w_pdfjs_require__.r = function(exports) {80 /******/ if (typeof Symbol !== "undefined" && Symbol.toStringTag) {81 /******/ Object.defineProperty(exports, Symbol.toStringTag, {82 value: "Module"83 });84 /******/85 }86 /******/ Object.defineProperty(exports, "__esModule", { value: true });87 /******/88 }; // create a fake namespace object // mode & 1: value is a module id, require it // mode & 2: merge all properties of value into the ns // mode & 4: return value when already ns object // mode & 8|1: behave like require89 /******/90 /******/ /******/ /******/ /******/ /******/ /******/ __w_pdfjs_require__.t = function(91 value,92 mode93 ) {94 /******/ if (mode & 1) value = __w_pdfjs_require__(value);95 /******/ if (mode & 8) return value;96 /******/ if (97 mode & 4 &&98 typeof value === "object" &&99 value &&100 value.__esModule101 )102 return value;103 /******/ var ns = Object.create(null);104 /******/ __w_pdfjs_require__.r(ns);105 /******/ Object.defineProperty(ns, "default", {106 enumerable: true,107 value: value108 });109 /******/ if (mode & 2 && typeof value != "string")110 for (var key in value)111 __w_pdfjs_require__.d(112 ns,113 key,114 function(key) {115 return value[key];116 }.bind(null, key)117 );118 /******/ return ns;119 /******/120 }; // getDefaultExport function for compatibility with non-harmony modules121 /******/122 /******/ /******/ __w_pdfjs_require__.n = function(module) {123 /******/ var getter =124 module && module.__esModule125 ? /******/ function getDefault() {126 return module["default"];127 }128 : /******/ function getModuleExports() {129 return module;130 };131 /******/ __w_pdfjs_require__.d(getter, "a", getter);132 /******/ return getter;133 /******/134 }; // Object.prototype.hasOwnProperty.call135 /******/136 /******/ /******/ __w_pdfjs_require__.o = function(object, property) {137 return Object.prototype.hasOwnProperty.call(object, property);138 }; // __webpack_public_path__139 /******/140 /******/ /******/ __w_pdfjs_require__.p = ""; // Load entry module and return exports141 /******/142 /******/143 /******/ /******/ return __w_pdfjs_require__((__w_pdfjs_require__.s = 0));144 /******/145 })(146 /************************************************************************/147 /******/ [148 /* 0 */149 /***/ function(module, exports, __w_pdfjs_require__) {150 "use strict";151 var pdfjsVersion = "2.2.93";152 var pdfjsBuild = "9b5a937f";153 var pdfjsSharedUtil = __w_pdfjs_require__(1);154 var pdfjsDisplayAPI = __w_pdfjs_require__(147);155 var pdfjsDisplayTextLayer = __w_pdfjs_require__(163);156 var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(164);157 var pdfjsDisplayDisplayUtils = __w_pdfjs_require__(152);158 var pdfjsDisplaySVG = __w_pdfjs_require__(165);159 var pdfjsDisplayWorkerOptions = __w_pdfjs_require__(157);160 var pdfjsDisplayAPICompatibility = __w_pdfjs_require__(154);161 {162 var isNodeJS = __w_pdfjs_require__(4);163 if (isNodeJS()) {164 var PDFNodeStream = __w_pdfjs_require__(166).PDFNodeStream;165 pdfjsDisplayAPI.setPDFNetworkStreamFactory(function(params) {166 return new PDFNodeStream(params);167 });168 } else {169 var PDFNetworkStream = __w_pdfjs_require__(169).PDFNetworkStream;170 var PDFFetchStream;171 if (pdfjsDisplayDisplayUtils.isFetchSupported()) {172 PDFFetchStream = __w_pdfjs_require__(170).PDFFetchStream;173 }174 pdfjsDisplayAPI.setPDFNetworkStreamFactory(function(params) {175 if (176 PDFFetchStream &&177 pdfjsDisplayDisplayUtils.isValidFetchUrl(params.url)178 ) {179 return new PDFFetchStream(params);180 }181 return new PDFNetworkStream(params);182 });183 }184 }185 exports.build = pdfjsDisplayAPI.build;186 exports.version = pdfjsDisplayAPI.version;187 exports.getDocument = pdfjsDisplayAPI.getDocument;188 exports.LoopbackPort = pdfjsDisplayAPI.LoopbackPort;189 exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport;190 exports.PDFWorker = pdfjsDisplayAPI.PDFWorker;191 exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer;192 exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer;193 exports.createPromiseCapability =194 pdfjsSharedUtil.createPromiseCapability;195 exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses;196 exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException;197 exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException;198 exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics;199 exports.NativeImageDecoding = pdfjsSharedUtil.NativeImageDecoding;200 exports.CMapCompressionType = pdfjsSharedUtil.CMapCompressionType;201 exports.PermissionFlag = pdfjsSharedUtil.PermissionFlag;202 exports.UnexpectedResponseException =203 pdfjsSharedUtil.UnexpectedResponseException;204 exports.OPS = pdfjsSharedUtil.OPS;205 exports.VerbosityLevel = pdfjsSharedUtil.VerbosityLevel;206 exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;207 exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;208 exports.createObjectURL = pdfjsSharedUtil.createObjectURL;209 exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;210 exports.shadow = pdfjsSharedUtil.shadow;211 exports.Util = pdfjsSharedUtil.Util;212 exports.ReadableStream = pdfjsSharedUtil.ReadableStream;213 exports.URL = pdfjsSharedUtil.URL;214 exports.RenderingCancelledException =215 pdfjsDisplayDisplayUtils.RenderingCancelledException;216 exports.getFilenameFromUrl =217 pdfjsDisplayDisplayUtils.getFilenameFromUrl;218 exports.LinkTarget = pdfjsDisplayDisplayUtils.LinkTarget;219 exports.addLinkAttributes = pdfjsDisplayDisplayUtils.addLinkAttributes;220 exports.loadScript = pdfjsDisplayDisplayUtils.loadScript;221 exports.GlobalWorkerOptions =222 pdfjsDisplayWorkerOptions.GlobalWorkerOptions;223 exports.apiCompatibilityParams =224 pdfjsDisplayAPICompatibility.apiCompatibilityParams;225 /***/226 },227 /* 1 */228 /***/ function(module, exports, __w_pdfjs_require__) {229 "use strict";230 Object.defineProperty(exports, "__esModule", {231 value: true232 });233 exports.arrayByteLength = arrayByteLength;234 exports.arraysToBytes = arraysToBytes;235 exports.assert = assert;236 exports.bytesToString = bytesToString;237 exports.createPromiseCapability = createPromiseCapability;238 exports.getVerbosityLevel = getVerbosityLevel;239 exports.info = info;240 exports.isArrayBuffer = isArrayBuffer;241 exports.isArrayEqual = isArrayEqual;242 exports.isBool = isBool;243 exports.isEmptyObj = isEmptyObj;244 exports.isNum = isNum;245 exports.isString = isString;246 exports.isSpace = isSpace;247 exports.isSameOrigin = isSameOrigin;248 exports.createValidAbsoluteUrl = createValidAbsoluteUrl;249 exports.isLittleEndian = isLittleEndian;250 exports.isEvalSupported = isEvalSupported;251 exports.log2 = log2;252 exports.readInt8 = readInt8;253 exports.readUint16 = readUint16;254 exports.readUint32 = readUint32;255 exports.removeNullCharacters = removeNullCharacters;256 exports.setVerbosityLevel = setVerbosityLevel;257 exports.shadow = shadow;258 exports.string32 = string32;259 exports.stringToBytes = stringToBytes;260 exports.stringToPDFString = stringToPDFString;261 exports.stringToUTF8String = stringToUTF8String;262 exports.utf8StringToString = utf8StringToString;263 exports.warn = warn;264 exports.unreachable = unreachable;265 Object.defineProperty(exports, "ReadableStream", {266 enumerable: true,267 get: function get() {268 return _streams_polyfill.ReadableStream;269 }270 });271 Object.defineProperty(exports, "URL", {272 enumerable: true,273 get: function get() {274 return _url_polyfill.URL;275 }276 });277 exports.createObjectURL = exports.FormatError = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.NativeImageDecoding = exports.MissingPDFException = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = void 0;278 __w_pdfjs_require__(2);279 var _streams_polyfill = __w_pdfjs_require__(143);280 var _url_polyfill = __w_pdfjs_require__(145);281 function _typeof(obj) {282 if (283 typeof Symbol === "function" &&284 typeof Symbol.iterator === "symbol"285 ) {286 _typeof = function _typeof(obj) {287 return typeof obj;288 };289 } else {290 _typeof = function _typeof(obj) {291 return obj &&292 typeof Symbol === "function" &&293 obj.constructor === Symbol &&294 obj !== Symbol.prototype295 ? "symbol"296 : typeof obj;297 };298 }299 return _typeof(obj);300 }301 var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];302 exports.IDENTITY_MATRIX = IDENTITY_MATRIX;303 var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];304 exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;305 var NativeImageDecoding = {306 NONE: "none",307 DECODE: "decode",308 DISPLAY: "display"309 };310 exports.NativeImageDecoding = NativeImageDecoding;311 var PermissionFlag = {312 PRINT: 0x04,313 MODIFY_CONTENTS: 0x08,314 COPY: 0x10,315 MODIFY_ANNOTATIONS: 0x20,316 FILL_INTERACTIVE_FORMS: 0x100,317 COPY_FOR_ACCESSIBILITY: 0x200,318 ASSEMBLE: 0x400,319 PRINT_HIGH_QUALITY: 0x800320 };321 exports.PermissionFlag = PermissionFlag;322 var TextRenderingMode = {323 FILL: 0,324 STROKE: 1,325 FILL_STROKE: 2,326 INVISIBLE: 3,327 FILL_ADD_TO_PATH: 4,328 STROKE_ADD_TO_PATH: 5,329 FILL_STROKE_ADD_TO_PATH: 6,330 ADD_TO_PATH: 7,331 FILL_STROKE_MASK: 3,332 ADD_TO_PATH_FLAG: 4333 };334 exports.TextRenderingMode = TextRenderingMode;335 var ImageKind = {336 GRAYSCALE_1BPP: 1,337 RGB_24BPP: 2,338 RGBA_32BPP: 3339 };340 exports.ImageKind = ImageKind;341 var AnnotationType = {342 TEXT: 1,343 LINK: 2,344 FREETEXT: 3,345 LINE: 4,346 SQUARE: 5,347 CIRCLE: 6,348 POLYGON: 7,349 POLYLINE: 8,350 HIGHLIGHT: 9,351 UNDERLINE: 10,352 SQUIGGLY: 11,353 STRIKEOUT: 12,354 STAMP: 13,355 CARET: 14,356 INK: 15,357 POPUP: 16,358 FILEATTACHMENT: 17,359 SOUND: 18,360 MOVIE: 19,361 WIDGET: 20,362 SCREEN: 21,363 PRINTERMARK: 22,364 TRAPNET: 23,365 WATERMARK: 24,366 THREED: 25,367 REDACT: 26368 };369 exports.AnnotationType = AnnotationType;370 var AnnotationFlag = {371 INVISIBLE: 0x01,372 HIDDEN: 0x02,373 PRINT: 0x04,374 NOZOOM: 0x08,375 NOROTATE: 0x10,376 NOVIEW: 0x20,377 READONLY: 0x40,378 LOCKED: 0x80,379 TOGGLENOVIEW: 0x100,380 LOCKEDCONTENTS: 0x200381 };382 exports.AnnotationFlag = AnnotationFlag;383 var AnnotationFieldFlag = {384 READONLY: 0x0000001,385 REQUIRED: 0x0000002,386 NOEXPORT: 0x0000004,387 MULTILINE: 0x0001000,388 PASSWORD: 0x0002000,389 NOTOGGLETOOFF: 0x0004000,390 RADIO: 0x0008000,391 PUSHBUTTON: 0x0010000,392 COMBO: 0x0020000,393 EDIT: 0x0040000,394 SORT: 0x0080000,395 FILESELECT: 0x0100000,396 MULTISELECT: 0x0200000,397 DONOTSPELLCHECK: 0x0400000,398 DONOTSCROLL: 0x0800000,399 COMB: 0x1000000,400 RICHTEXT: 0x2000000,401 RADIOSINUNISON: 0x2000000,402 COMMITONSELCHANGE: 0x4000000403 };404 exports.AnnotationFieldFlag = AnnotationFieldFlag;405 var AnnotationBorderStyleType = {406 SOLID: 1,407 DASHED: 2,408 BEVELED: 3,409 INSET: 4,410 UNDERLINE: 5411 };412 exports.AnnotationBorderStyleType = AnnotationBorderStyleType;413 var StreamType = {414 UNKNOWN: 0,415 FLATE: 1,416 LZW: 2,417 DCT: 3,418 JPX: 4,419 JBIG: 5,420 A85: 6,421 AHX: 7,422 CCF: 8,423 RL: 9424 };425 exports.StreamType = StreamType;426 var FontType = {427 UNKNOWN: 0,428 TYPE1: 1,429 TYPE1C: 2,430 CIDFONTTYPE0: 3,431 CIDFONTTYPE0C: 4,432 TRUETYPE: 5,433 CIDFONTTYPE2: 6,434 TYPE3: 7,435 OPENTYPE: 8,436 TYPE0: 9,437 MMTYPE1: 10438 };439 exports.FontType = FontType;440 var VerbosityLevel = {441 ERRORS: 0,442 WARNINGS: 1,443 INFOS: 5444 };445 exports.VerbosityLevel = VerbosityLevel;446 var CMapCompressionType = {447 NONE: 0,448 BINARY: 1,449 STREAM: 2450 };451 exports.CMapCompressionType = CMapCompressionType;452 var OPS = {453 dependency: 1,454 setLineWidth: 2,455 setLineCap: 3,456 setLineJoin: 4,457 setMiterLimit: 5,458 setDash: 6,459 setRenderingIntent: 7,460 setFlatness: 8,461 setGState: 9,462 save: 10,463 restore: 11,464 transform: 12,465 moveTo: 13,466 lineTo: 14,467 curveTo: 15,468 curveTo2: 16,469 curveTo3: 17,470 closePath: 18,471 rectangle: 19,472 stroke: 20,473 closeStroke: 21,474 fill: 22,475 eoFill: 23,476 fillStroke: 24,477 eoFillStroke: 25,478 closeFillStroke: 26,479 closeEOFillStroke: 27,480 endPath: 28,481 clip: 29,482 eoClip: 30,483 beginText: 31,484 endText: 32,485 setCharSpacing: 33,486 setWordSpacing: 34,487 setHScale: 35,488 setLeading: 36,489 setFont: 37,490 setTextRenderingMode: 38,491 setTextRise: 39,492 moveText: 40,493 setLeadingMoveText: 41,494 setTextMatrix: 42,495 nextLine: 43,496 showText: 44,497 showSpacedText: 45,498 nextLineShowText: 46,499 nextLineSetSpacingShowText: 47,500 setCharWidth: 48,501 setCharWidthAndBounds: 49,502 setStrokeColorSpace: 50,503 setFillColorSpace: 51,504 setStrokeColor: 52,505 setStrokeColorN: 53,506 setFillColor: 54,507 setFillColorN: 55,508 setStrokeGray: 56,509 setFillGray: 57,510 setStrokeRGBColor: 58,511 setFillRGBColor: 59,512 setStrokeCMYKColor: 60,513 setFillCMYKColor: 61,514 shadingFill: 62,515 beginInlineImage: 63,516 beginImageData: 64,517 endInlineImage: 65,518 paintXObject: 66,519 markPoint: 67,520 markPointProps: 68,521 beginMarkedContent: 69,522 beginMarkedContentProps: 70,523 endMarkedContent: 71,524 beginCompat: 72,525 endCompat: 73,526 paintFormXObjectBegin: 74,527 paintFormXObjectEnd: 75,528 beginGroup: 76,529 endGroup: 77,530 beginAnnotations: 78,531 endAnnotations: 79,532 beginAnnotation: 80,533 endAnnotation: 81,534 paintJpegXObject: 82,535 paintImageMaskXObject: 83,536 paintImageMaskXObjectGroup: 84,537 paintImageXObject: 85,538 paintInlineImageXObject: 86,539 paintInlineImageXObjectGroup: 87,540 paintImageXObjectRepeat: 88,541 paintImageMaskXObjectRepeat: 89,542 paintSolidColorImageMask: 90,543 constructPath: 91544 };545 exports.OPS = OPS;546 var UNSUPPORTED_FEATURES = {547 unknown: "unknown",548 forms: "forms",549 javaScript: "javaScript",550 smask: "smask",551 shadingPattern: "shadingPattern",552 font: "font"553 };554 exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;555 var PasswordResponses = {556 NEED_PASSWORD: 1,557 INCORRECT_PASSWORD: 2558 };559 exports.PasswordResponses = PasswordResponses;560 var verbosity = VerbosityLevel.WARNINGS;561 function setVerbosityLevel(level) {562 if (Number.isInteger(level)) {563 verbosity = level;564 }565 }566 function getVerbosityLevel() {567 return verbosity;568 }569 function info(msg) {570 if (verbosity >= VerbosityLevel.INFOS) {571 console.log("Info: " + msg);572 }573 }574 function warn(msg) {575 if (verbosity >= VerbosityLevel.WARNINGS) {576 console.log("Warning: " + msg);577 }578 }579 function unreachable(msg) {580 throw new Error(msg);581 }582 function assert(cond, msg) {583 if (!cond) {584 unreachable(msg);585 }586 }587 function isSameOrigin(baseUrl, otherUrl) {588 try {589 var base = new _url_polyfill.URL(baseUrl);590 if (!base.origin || base.origin === "null") {591 return false;592 }593 } catch (e) {594 return false;595 }596 var other = new _url_polyfill.URL(otherUrl, base);597 return base.origin === other.origin;598 }599 function _isValidProtocol(url) {600 if (!url) {601 return false;602 }603 switch (url.protocol) {604 case "http:":605 case "https:":606 case "ftp:":607 case "mailto:":608 case "tel:":609 return true;610 default:611 return false;612 }613 }614 function createValidAbsoluteUrl(url, baseUrl) {615 if (!url) {616 return null;617 }618 try {619 var absoluteUrl = baseUrl620 ? new _url_polyfill.URL(url, baseUrl)621 : new _url_polyfill.URL(url);622 if (_isValidProtocol(absoluteUrl)) {623 return absoluteUrl;624 }625 } catch (ex) {}626 return null;627 }628 function shadow(obj, prop, value) {629 Object.defineProperty(obj, prop, {630 value: value,631 enumerable: true,632 configurable: true,633 writable: false634 });635 return value;636 }637 var PasswordException = (function PasswordExceptionClosure() {638 function PasswordException(msg, code) {639 this.name = "PasswordException";640 this.message = msg;641 this.code = code;642 }643 PasswordException.prototype = new Error();644 PasswordException.constructor = PasswordException;645 return PasswordException;646 })();647 exports.PasswordException = PasswordException;648 var UnknownErrorException = (function UnknownErrorExceptionClosure() {649 function UnknownErrorException(msg, details) {650 this.name = "UnknownErrorException";651 this.message = msg;652 this.details = details;653 }654 UnknownErrorException.prototype = new Error();655 UnknownErrorException.constructor = UnknownErrorException;656 return UnknownErrorException;657 })();658 exports.UnknownErrorException = UnknownErrorException;659 var InvalidPDFException = (function InvalidPDFExceptionClosure() {660 function InvalidPDFException(msg) {661 this.name = "InvalidPDFException";662 this.message = msg;663 }664 InvalidPDFException.prototype = new Error();665 InvalidPDFException.constructor = InvalidPDFException;666 return InvalidPDFException;667 })();668 exports.InvalidPDFException = InvalidPDFException;669 var MissingPDFException = (function MissingPDFExceptionClosure() {670 function MissingPDFException(msg) {671 this.name = "MissingPDFException";672 this.message = msg;673 }674 MissingPDFException.prototype = new Error();675 MissingPDFException.constructor = MissingPDFException;676 return MissingPDFException;677 })();678 exports.MissingPDFException = MissingPDFException;679 var UnexpectedResponseException = (function UnexpectedResponseExceptionClosure() {680 function UnexpectedResponseException(msg, status) {681 this.name = "UnexpectedResponseException";682 this.message = msg;683 this.status = status;684 }685 UnexpectedResponseException.prototype = new Error();686 UnexpectedResponseException.constructor = UnexpectedResponseException;687 return UnexpectedResponseException;688 })();689 exports.UnexpectedResponseException = UnexpectedResponseException;690 var FormatError = (function FormatErrorClosure() {691 function FormatError(msg) {692 this.message = msg;693 }694 FormatError.prototype = new Error();695 FormatError.prototype.name = "FormatError";696 FormatError.constructor = FormatError;697 return FormatError;698 })();699 exports.FormatError = FormatError;700 var AbortException = (function AbortExceptionClosure() {701 function AbortException(msg) {702 this.name = "AbortException";703 this.message = msg;704 }705 AbortException.prototype = new Error();706 AbortException.constructor = AbortException;707 return AbortException;708 })();709 exports.AbortException = AbortException;710 var NullCharactersRegExp = /\x00/g;711 function removeNullCharacters(str) {712 if (typeof str !== "string") {713 warn("The argument for removeNullCharacters must be a string.");714 return str;715 }716 return str.replace(NullCharactersRegExp, "");717 }718 function bytesToString(bytes) {719 assert(720 bytes !== null &&721 _typeof(bytes) === "object" &&722 bytes.length !== undefined,723 "Invalid argument for bytesToString"724 );725 var length = bytes.length;726 var MAX_ARGUMENT_COUNT = 8192;727 if (length < MAX_ARGUMENT_COUNT) {728 return String.fromCharCode.apply(null, bytes);729 }730 var strBuf = [];731 for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {732 var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);733 var chunk = bytes.subarray(i, chunkEnd);734 strBuf.push(String.fromCharCode.apply(null, chunk));735 }736 return strBuf.join("");737 }738 function stringToBytes(str) {739 assert(typeof str === "string", "Invalid argument for stringToBytes");740 var length = str.length;741 var bytes = new Uint8Array(length);742 for (var i = 0; i < length; ++i) {743 bytes[i] = str.charCodeAt(i) & 0xff;744 }745 return bytes;746 }747 function arrayByteLength(arr) {748 if (arr.length !== undefined) {749 return arr.length;750 }751 assert(arr.byteLength !== undefined);752 return arr.byteLength;753 }754 function arraysToBytes(arr) {755 if (arr.length === 1 && arr[0] instanceof Uint8Array) {756 return arr[0];757 }758 var resultLength = 0;759 var i,760 ii = arr.length;761 var item, itemLength;762 for (i = 0; i < ii; i++) {763 item = arr[i];764 itemLength = arrayByteLength(item);765 resultLength += itemLength;766 }767 var pos = 0;768 var data = new Uint8Array(resultLength);769 for (i = 0; i < ii; i++) {770 item = arr[i];771 if (!(item instanceof Uint8Array)) {772 if (typeof item === "string") {773 item = stringToBytes(item);774 } else {775 item = new Uint8Array(item);776 }777 }778 itemLength = item.byteLength;779 data.set(item, pos);780 pos += itemLength;781 }782 return data;783 }784 function string32(value) {785 return String.fromCharCode(786 (value >> 24) & 0xff,787 (value >> 16) & 0xff,788 (value >> 8) & 0xff,789 value & 0xff790 );791 }792 function log2(x) {793 if (x <= 0) {794 return 0;795 }796 return Math.ceil(Math.log2(x));797 }798 function readInt8(data, start) {799 return (data[start] << 24) >> 24;800 }801 function readUint16(data, offset) {802 return (data[offset] << 8) | data[offset + 1];803 }804 function readUint32(data, offset) {805 return (806 ((data[offset] << 24) |807 (data[offset + 1] << 16) |808 (data[offset + 2] << 8) |809 data[offset + 3]) >>>810 0811 );812 }813 function isLittleEndian() {814 var buffer8 = new Uint8Array(4);815 buffer8[0] = 1;816 var view32 = new Uint32Array(buffer8.buffer, 0, 1);817 return view32[0] === 1;818 }819 function isEvalSupported() {820 try {821 new Function("");822 return true;823 } catch (e) {824 return false;825 }826 }827 var Util = (function UtilClosure() {828 function Util() {}829 var rgbBuf = ["rgb(", 0, ",", 0, ",", 0, ")"];830 Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {831 rgbBuf[1] = r;832 rgbBuf[3] = g;833 rgbBuf[5] = b;834 return rgbBuf.join("");835 };836 Util.transform = function Util_transform(m1, m2) {837 return [838 m1[0] * m2[0] + m1[2] * m2[1],839 m1[1] * m2[0] + m1[3] * m2[1],840 m1[0] * m2[2] + m1[2] * m2[3],841 m1[1] * m2[2] + m1[3] * m2[3],842 m1[0] * m2[4] + m1[2] * m2[5] + m1[4],843 m1[1] * m2[4] + m1[3] * m2[5] + m1[5]844 ];845 };846 Util.applyTransform = function Util_applyTransform(p, m) {847 var xt = p[0] * m[0] + p[1] * m[2] + m[4];848 var yt = p[0] * m[1] + p[1] * m[3] + m[5];849 return [xt, yt];850 };851 Util.applyInverseTransform = function Util_applyInverseTransform(852 p,853 m854 ) {855 var d = m[0] * m[3] - m[1] * m[2];856 var xt =857 (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;858 var yt =859 (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;860 return [xt, yt];861 };862 Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(863 r,864 m865 ) {866 var p1 = Util.applyTransform(r, m);867 var p2 = Util.applyTransform(r.slice(2, 4), m);868 var p3 = Util.applyTransform([r[0], r[3]], m);869 var p4 = Util.applyTransform([r[2], r[1]], m);870 return [871 Math.min(p1[0], p2[0], p3[0], p4[0]),872 Math.min(p1[1], p2[1], p3[1], p4[1]),873 Math.max(p1[0], p2[0], p3[0], p4[0]),874 Math.max(p1[1], p2[1], p3[1], p4[1])875 ];876 };877 Util.inverseTransform = function Util_inverseTransform(m) {878 var d = m[0] * m[3] - m[1] * m[2];879 return [880 m[3] / d,881 -m[1] / d,882 -m[2] / d,883 m[0] / d,884 (m[2] * m[5] - m[4] * m[3]) / d,885 (m[4] * m[1] - m[5] * m[0]) / d886 ];887 };888 Util.apply3dTransform = function Util_apply3dTransform(m, v) {889 return [890 m[0] * v[0] + m[1] * v[1] + m[2] * v[2],891 m[3] * v[0] + m[4] * v[1] + m[5] * v[2],892 m[6] * v[0] + m[7] * v[1] + m[8] * v[2]893 ];894 };895 Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(896 m897 ) {898 var transpose = [m[0], m[2], m[1], m[3]];899 var a = m[0] * transpose[0] + m[1] * transpose[2];900 var b = m[0] * transpose[1] + m[1] * transpose[3];901 var c = m[2] * transpose[0] + m[3] * transpose[2];902 var d = m[2] * transpose[1] + m[3] * transpose[3];903 var first = (a + d) / 2;904 var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;905 var sx = first + second || 1;906 var sy = first - second || 1;907 return [Math.sqrt(sx), Math.sqrt(sy)];908 };909 Util.normalizeRect = function Util_normalizeRect(rect) {910 var r = rect.slice(0);911 if (rect[0] > rect[2]) {912 r[0] = rect[2];913 r[2] = rect[0];914 }915 if (rect[1] > rect[3]) {916 r[1] = rect[3];917 r[3] = rect[1];918 }919 return r;920 };921 Util.intersect = function Util_intersect(rect1, rect2) {922 function compare(a, b) {923 return a - b;924 }925 var orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(926 compare927 ),928 orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare),929 result = [];930 rect1 = Util.normalizeRect(rect1);931 rect2 = Util.normalizeRect(rect2);932 if (933 (orderedX[0] === rect1[0] && orderedX[1] === rect2[0]) ||934 (orderedX[0] === rect2[0] && orderedX[1] === rect1[0])935 ) {936 result[0] = orderedX[1];937 result[2] = orderedX[2];938 } else {939 return false;940 }941 if (942 (orderedY[0] === rect1[1] && orderedY[1] === rect2[1]) ||943 (orderedY[0] === rect2[1] && orderedY[1] === rect1[1])944 ) {945 result[1] = orderedY[1];946 result[3] = orderedY[2];947 } else {948 return false;949 }950 return result;951 };952 return Util;953 })();954 exports.Util = Util;955 var PDFStringTranslateTable = [956 0,957 0,958 0,959 0,960 0,961 0,962 0,963 0,964 0,965 0,966 0,967 0,968 0,969 0,970 0,971 0,972 0,973 0,974 0,975 0,976 0,977 0,978 0,979 0,980 0x2d8,981 0x2c7,982 0x2c6,983 0x2d9,984 0x2dd,985 0x2db,986 0x2da,987 0x2dc,988 0,989 0,990 0,991 0,992 0,993 0,994 0,995 0,996 0,997 0,998 0,999 0,1000 0,1001 0,1002 0,1003 0,1004 0,1005 0,1006 0,1007 0,1008 0,1009 0,1010 0,1011 0,1012 0,1013 0,1014 0,1015 0,1016 0,1017 0,1018 0,1019 0,1020 0,1021 0,1022 0,1023 0,1024 0,1025 0,1026 0,1027 0,1028 0,1029 0,1030 0,1031 0,1032 0,1033 0,1034 0,1035 0,1036 0,1037 0,1038 0,1039 0,1040 0,1041 0,1042 0,1043 0,1044 0,1045 0,1046 0,1047 0,1048 0,1049 0,1050 0,1051 0,1052 0,1053 0,1054 0,1055 0,1056 0,1057 0,1058 0,1059 0,1060 0,1061 0,1062 0,1063 0,1064 0,1065 0,1066 0,1067 0,1068 0,1069 0,1070 0,1071 0,1072 0,1073 0,1074 0,1075 0,1076 0,1077 0,1078 0,1079 0,1080 0,1081 0,1082 0,1083 0,1084 0x2022,1085 0x2020,1086 0x2021,1087 0x2026,1088 0x2014,1089 0x2013,1090 0x192,1091 0x2044,1092 0x2039,1093 0x203a,1094 0x2212,1095 0x2030,1096 0x201e,1097 0x201c,1098 0x201d,1099 0x2018,1100 0x2019,1101 0x201a,1102 0x2122,1103 0xfb01,1104 0xfb02,1105 0x141,1106 0x152,1107 0x160,1108 0x178,1109 0x17d,1110 0x131,1111 0x142,1112 0x153,1113 0x161,1114 0x17e,1115 0,1116 0x20ac1117 ];1118 function stringToPDFString(str) {1119 var i,1120 n = str.length,1121 strBuf = [];1122 if (str[0] === "\xFE" && str[1] === "\xFF") {1123 for (i = 2; i < n; i += 2) {1124 strBuf.push(1125 String.fromCharCode(1126 (str.charCodeAt(i) << 8) | str.charCodeAt(i + 1)1127 )1128 );1129 }1130 } else {1131 for (i = 0; i < n; ++i) {1132 var code = PDFStringTranslateTable[str.charCodeAt(i)];1133 strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));1134 }1135 }1136 return strBuf.join("");1137 }1138 function stringToUTF8String(str) {1139 return decodeURIComponent(escape(str));1140 }1141 function utf8StringToString(str) {1142 return unescape(encodeURIComponent(str));1143 }1144 function isEmptyObj(obj) {1145 for (var key in obj) {1146 return false;1147 }1148 return true;1149 }1150 function isBool(v) {1151 return typeof v === "boolean";1152 }1153 function isNum(v) {1154 return typeof v === "number";1155 }1156 function isString(v) {1157 return typeof v === "string";1158 }1159 function isArrayBuffer(v) {1160 return (1161 _typeof(v) === "object" && v !== null && v.byteLength !== undefined1162 );1163 }1164 function isArrayEqual(arr1, arr2) {1165 if (arr1.length !== arr2.length) {1166 return false;1167 }1168 return arr1.every(function(element, index) {1169 return element === arr2[index];1170 });1171 }1172 function isSpace(ch) {1173 return ch === 0x20 || ch === 0x09 || ch === 0x0d || ch === 0x0a;1174 }1175 function createPromiseCapability() {1176 var capability = Object.create(null);1177 var isSettled = false;1178 Object.defineProperty(capability, "settled", {1179 get: function get() {1180 return isSettled;1181 }1182 });1183 capability.promise = new Promise(function(resolve, reject) {1184 capability.resolve = function(data) {1185 isSettled = true;1186 resolve(data);1187 };1188 capability.reject = function(reason) {1189 isSettled = true;1190 reject(reason);1191 };1192 });1193 return capability;1194 }1195 var createObjectURL = (function createObjectURLClosure() {1196 var digits =1197 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";1198 return function createObjectURL(data, contentType) {1199 var forceDataSchema =1200 arguments.length > 2 && arguments[2] !== undefined1201 ? arguments[2]1202 : false;1203 if (!forceDataSchema && _url_polyfill.URL.createObjectURL) {1204 var blob = new Blob([data], {1205 type: contentType1206 });1207 return _url_polyfill.URL.createObjectURL(blob);1208 }1209 var buffer = "data:" + contentType + ";base64,";1210 for (var i = 0, ii = data.length; i < ii; i += 3) {1211 var b1 = data[i] & 0xff;1212 var b2 = data[i + 1] & 0xff;1213 var b3 = data[i + 2] & 0xff;1214 var d1 = b1 >> 2,1215 d2 = ((b1 & 3) << 4) | (b2 >> 4);1216 var d3 = i + 1 < ii ? ((b2 & 0xf) << 2) | (b3 >> 6) : 64;1217 var d4 = i + 2 < ii ? b3 & 0x3f : 64;1218 buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];1219 }1220 return buffer;1221 };1222 })();1223 exports.createObjectURL = createObjectURL;1224 /***/1225 },1226 /* 2 */1227 /***/ function(module, exports, __w_pdfjs_require__) {1228 "use strict";1229 function _typeof(obj) {1230 if (1231 typeof Symbol === "function" &&1232 typeof Symbol.iterator === "symbol"1233 ) {1234 _typeof = function _typeof(obj) {1235 return typeof obj;1236 };1237 } else {1238 _typeof = function _typeof(obj) {1239 return obj &&1240 typeof Symbol === "function" &&1241 obj.constructor === Symbol &&1242 obj !== Symbol.prototype1243 ? "symbol"1244 : typeof obj;1245 };1246 }1247 return _typeof(obj);1248 }1249 var globalScope = __w_pdfjs_require__(3);1250 if (!globalScope._pdfjsCompatibilityChecked) {1251 globalScope._pdfjsCompatibilityChecked = true;1252 var isNodeJS = __w_pdfjs_require__(4);1253 var hasDOM =1254 (typeof window === "undefined" ? "undefined" : _typeof(window)) ===1255 "object" &&1256 (typeof document === "undefined"1257 ? "undefined"1258 : _typeof(document)) === "object";1259 (function checkNodeBtoa() {1260 if (globalScope.btoa || !isNodeJS()) {1261 return;1262 }1263 globalScope.btoa = function(chars) {1264 return Buffer.from(chars, "binary").toString("base64");1265 };1266 })();1267 (function checkNodeAtob() {1268 if (globalScope.atob || !isNodeJS()) {1269 return;1270 }1271 globalScope.atob = function(input) {1272 return Buffer.from(input, "base64").toString("binary");1273 };1274 })();1275 (function checkChildNodeRemove() {1276 if (!hasDOM) {1277 return;1278 }1279 if (typeof Element.prototype.remove !== "undefined") {1280 return;1281 }1282 Element.prototype.remove = function() {1283 if (this.parentNode) {1284 this.parentNode.removeChild(this);1285 }1286 };1287 })();1288 (function checkDOMTokenListAddRemove() {1289 if (!hasDOM || isNodeJS()) {1290 return;1291 }1292 var div = document.createElement("div");1293 div.classList.add("testOne", "testTwo");1294 if (1295 div.classList.contains("testOne") === true &&1296 div.classList.contains("testTwo") === true1297 ) {1298 return;1299 }1300 var OriginalDOMTokenListAdd = DOMTokenList.prototype.add;1301 var OriginalDOMTokenListRemove = DOMTokenList.prototype.remove;1302 DOMTokenList.prototype.add = function() {1303 for (1304 var _len = arguments.length, tokens = new Array(_len), _key = 0;1305 _key < _len;1306 _key++1307 ) {1308 tokens[_key] = arguments[_key];1309 }1310 for (var _i = 0; _i < tokens.length; _i++) {1311 var token = tokens[_i];1312 OriginalDOMTokenListAdd.call(this, token);1313 }1314 };1315 DOMTokenList.prototype.remove = function() {1316 for (1317 var _len2 = arguments.length,1318 tokens = new Array(_len2),1319 _key2 = 0;1320 _key2 < _len2;1321 _key2++1322 ) {1323 tokens[_key2] = arguments[_key2];1324 }1325 for (var _i2 = 0; _i2 < tokens.length; _i2++) {1326 var token = tokens[_i2];1327 OriginalDOMTokenListRemove.call(this, token);1328 }1329 };1330 })();1331 (function checkDOMTokenListToggle() {1332 if (!hasDOM || isNodeJS()) {1333 return;1334 }1335 var div = document.createElement("div");1336 if (div.classList.toggle("test", 0) === false) {1337 return;1338 }1339 DOMTokenList.prototype.toggle = function(token) {1340 var force =1341 arguments.length > 1 ? !!arguments[1] : !this.contains(token);1342 return this[force ? "add" : "remove"](token), force;1343 };1344 })();1345 (function checkStringStartsWith() {1346 if (String.prototype.startsWith) {1347 return;1348 }1349 __w_pdfjs_require__(5);1350 })();1351 (function checkStringEndsWith() {1352 if (String.prototype.endsWith) {1353 return;1354 }1355 __w_pdfjs_require__(36);1356 })();1357 (function checkStringIncludes() {1358 if (String.prototype.includes) {1359 return;1360 }1361 __w_pdfjs_require__(38);1362 })();1363 (function checkArrayIncludes() {1364 if (Array.prototype.includes) {1365 return;1366 }1367 __w_pdfjs_require__(40);1368 })();1369 (function checkArrayFrom() {1370 if (Array.from) {1371 return;1372 }1373 __w_pdfjs_require__(47);1374 })();1375 (function checkObjectAssign() {1376 if (Object.assign) {1377 return;1378 }1379 __w_pdfjs_require__(70);1380 })();1381 (function checkMathLog2() {1382 if (Math.log2) {1383 return;1384 }1385 Math.log2 = __w_pdfjs_require__(75);1386 })();1387 (function checkNumberIsNaN() {1388 if (Number.isNaN) {1389 return;1390 }1391 Number.isNaN = __w_pdfjs_require__(77);1392 })();1393 (function checkNumberIsInteger() {1394 if (Number.isInteger) {1395 return;1396 }1397 Number.isInteger = __w_pdfjs_require__(79);1398 })();1399 (function checkPromise() {1400 if (1401 globalScope.Promise &&1402 globalScope.Promise.prototype &&1403 globalScope.Promise.prototype.finally1404 ) {1405 return;1406 }1407 globalScope.Promise = __w_pdfjs_require__(82);1408 })();1409 (function checkWeakMap() {1410 if (globalScope.WeakMap) {1411 return;1412 }1413 globalScope.WeakMap = __w_pdfjs_require__(102);1414 })();1415 (function checkWeakSet() {1416 if (globalScope.WeakSet) {1417 return;1418 }1419 globalScope.WeakSet = __w_pdfjs_require__(119);1420 })();1421 (function checkStringCodePointAt() {1422 if (String.codePointAt) {1423 return;1424 }1425 String.codePointAt = __w_pdfjs_require__(123);1426 })();1427 (function checkStringFromCodePoint() {1428 if (String.fromCodePoint) {1429 return;1430 }1431 String.fromCodePoint = __w_pdfjs_require__(125);1432 })();1433 (function checkSymbol() {1434 if (globalScope.Symbol) {1435 return;1436 }1437 __w_pdfjs_require__(127);1438 })();1439 (function checkStringPadStart() {1440 if (String.prototype.padStart) {1441 return;1442 }1443 __w_pdfjs_require__(134);1444 })();1445 (function checkStringPadEnd() {1446 if (String.prototype.padEnd) {1447 return;1448 }1449 __w_pdfjs_require__(138);1450 })();1451 (function checkObjectValues() {1452 if (Object.values) {1453 return;1454 }1455 Object.values = __w_pdfjs_require__(140);1456 })();1457 }1458 /***/1459 },1460 /* 3 */1461 /***/ function(module, exports, __w_pdfjs_require__) {1462 "use strict";1463 module.exports =1464 typeof window !== "undefined" && window.Math === Math1465 ? window1466 : typeof global !== "undefined" && global.Math === Math1467 ? global1468 : typeof self !== "undefined" && self.Math === Math1469 ? self1470 : {};1471 /***/1472 },1473 /* 4 */1474 /***/ function(module, exports, __w_pdfjs_require__) {1475 "use strict";1476 function _typeof(obj) {1477 if (1478 typeof Symbol === "function" &&1479 typeof Symbol.iterator === "symbol"1480 ) {1481 _typeof = function _typeof(obj) {1482 return typeof obj;1483 };1484 } else {1485 _typeof = function _typeof(obj) {1486 return obj &&1487 typeof Symbol === "function" &&1488 obj.constructor === Symbol &&1489 obj !== Symbol.prototype1490 ? "symbol"1491 : typeof obj;1492 };1493 }1494 return _typeof(obj);1495 }1496 module.exports = function isNodeJS() {1497 return (1498 (typeof process === "undefined"1499 ? "undefined"1500 : _typeof(process)) === "object" &&1501 process + "" === "[object process]" &&1502 !process.versions["nw"]1503 );1504 };1505 /***/1506 },1507 /* 5 */1508 /***/ function(module, exports, __w_pdfjs_require__) {1509 "use strict";1510 __w_pdfjs_require__(6);1511 module.exports = __w_pdfjs_require__(9).String.startsWith;1512 /***/1513 },1514 /* 6 */1515 /***/ function(module, exports, __w_pdfjs_require__) {1516 "use strict";1517 var $export = __w_pdfjs_require__(7);1518 var toLength = __w_pdfjs_require__(28);1519 var context = __w_pdfjs_require__(30);1520 var STARTS_WITH = "startsWith";1521 var $startsWith = ""[STARTS_WITH];1522 $export(1523 $export.P + $export.F * __w_pdfjs_require__(35)(STARTS_WITH),1524 "String",1525 {1526 startsWith: function startsWith(searchString) {1527 var that = context(this, searchString, STARTS_WITH);1528 var index = toLength(1529 Math.min(1530 arguments.length > 1 ? arguments[1] : undefined,1531 that.length1532 )1533 );1534 var search = String(searchString);1535 return $startsWith1536 ? $startsWith.call(that, search, index)1537 : that.slice(index, index + search.length) === search;1538 }1539 }1540 );1541 /***/1542 },1543 /* 7 */1544 /***/ function(module, exports, __w_pdfjs_require__) {1545 "use strict";1546 var global = __w_pdfjs_require__(8);1547 var core = __w_pdfjs_require__(9);1548 var hide = __w_pdfjs_require__(10);1549 var redefine = __w_pdfjs_require__(20);1550 var ctx = __w_pdfjs_require__(26);1551 var PROTOTYPE = "prototype";1552 var $export = function $export(type, name, source) {1553 var IS_FORCED = type & $export.F;1554 var IS_GLOBAL = type & $export.G;1555 var IS_STATIC = type & $export.S;1556 var IS_PROTO = type & $export.P;1557 var IS_BIND = type & $export.B;1558 var target = IS_GLOBAL1559 ? global1560 : IS_STATIC1561 ? global[name] || (global[name] = {})1562 : (global[name] || {})[PROTOTYPE];1563 var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});1564 var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});1565 var key, own, out, exp;1566 if (IS_GLOBAL) source = name;1567 for (key in source) {1568 own = !IS_FORCED && target && target[key] !== undefined;1569 out = (own ? target : source)[key];1570 exp =1571 IS_BIND && own1572 ? ctx(out, global)1573 : IS_PROTO && typeof out == "function"1574 ? ctx(Function.call, out)1575 : out;1576 if (target) redefine(target, key, out, type & $export.U);1577 if (exports[key] != out) hide(exports, key, exp);1578 if (IS_PROTO && expProto[key] != out) expProto[key] = out;1579 }1580 };1581 global.core = core;1582 $export.F = 1;1583 $export.G = 2;1584 $export.S = 4;1585 $export.P = 8;1586 $export.B = 16;1587 $export.W = 32;1588 $export.U = 64;1589 $export.R = 128;1590 module.exports = $export;1591 /***/1592 },1593 /* 8 */1594 /***/ function(module, exports, __w_pdfjs_require__) {1595 "use strict";1596 var global = (module.exports =1597 typeof window != "undefined" && window.Math == Math1598 ? window1599 : typeof self != "undefined" && self.Math == Math1600 ? self1601 : Function("return this")());1602 if (typeof __g == "number") __g = global;1603 /***/1604 },1605 /* 9 */1606 /***/ function(module, exports, __w_pdfjs_require__) {1607 "use strict";1608 var core = (module.exports = {1609 version: "2.6.5"1610 });1611 if (typeof __e == "number") __e = core;1612 /***/1613 },1614 /* 10 */1615 /***/ function(module, exports, __w_pdfjs_require__) {1616 "use strict";1617 var dP = __w_pdfjs_require__(11);1618 var createDesc = __w_pdfjs_require__(19);1619 module.exports = __w_pdfjs_require__(15)1620 ? function(object, key, value) {1621 return dP.f(object, key, createDesc(1, value));1622 }1623 : function(object, key, value) {1624 object[key] = value;1625 return object;1626 };1627 /***/1628 },1629 /* 11 */1630 /***/ function(module, exports, __w_pdfjs_require__) {1631 "use strict";1632 var anObject = __w_pdfjs_require__(12);1633 var IE8_DOM_DEFINE = __w_pdfjs_require__(14);1634 var toPrimitive = __w_pdfjs_require__(18);1635 var dP = Object.defineProperty;1636 exports.f = __w_pdfjs_require__(15)1637 ? Object.defineProperty1638 : function defineProperty(O, P, Attributes) {1639 anObject(O);1640 P = toPrimitive(P, true);1641 anObject(Attributes);1642 if (IE8_DOM_DEFINE)1643 try {1644 return dP(O, P, Attributes);1645 } catch (e) {}1646 if ("get" in Attributes || "set" in Attributes)1647 throw TypeError("Accessors not supported!");1648 if ("value" in Attributes) O[P] = Attributes.value;1649 return O;1650 };1651 /***/1652 },1653 /* 12 */1654 /***/ function(module, exports, __w_pdfjs_require__) {1655 "use strict";1656 var isObject = __w_pdfjs_require__(13);1657 module.exports = function(it) {1658 if (!isObject(it)) throw TypeError(it + " is not an object!");1659 return it;1660 };1661 /***/1662 },1663 /* 13 */1664 /***/ function(module, exports, __w_pdfjs_require__) {1665 "use strict";1666 function _typeof(obj) {1667 if (1668 typeof Symbol === "function" &&1669 typeof Symbol.iterator === "symbol"1670 ) {1671 _typeof = function _typeof(obj) {1672 return typeof obj;1673 };1674 } else {1675 _typeof = function _typeof(obj) {1676 return obj &&1677 typeof Symbol === "function" &&1678 obj.constructor === Symbol &&1679 obj !== Symbol.prototype1680 ? "symbol"1681 : typeof obj;1682 };1683 }1684 return _typeof(obj);1685 }1686 module.exports = function(it) {1687 return _typeof(it) === "object"1688 ? it !== null1689 : typeof it === "function";1690 };1691 /***/1692 },1693 /* 14 */1694 /***/ function(module, exports, __w_pdfjs_require__) {1695 "use strict";1696 module.exports =1697 !__w_pdfjs_require__(15) &&1698 !__w_pdfjs_require__(16)(function() {1699 return (1700 Object.defineProperty(__w_pdfjs_require__(17)("div"), "a", {1701 get: function get() {1702 return 7;1703 }1704 }).a != 71705 );1706 });1707 /***/1708 },1709 /* 15 */1710 /***/ function(module, exports, __w_pdfjs_require__) {1711 "use strict";1712 module.exports = !__w_pdfjs_require__(16)(function() {1713 return (1714 Object.defineProperty({}, "a", {1715 get: function get() {1716 return 7;1717 }1718 }).a != 71719 );1720 });1721 /***/1722 },1723 /* 16 */1724 /***/ function(module, exports, __w_pdfjs_require__) {1725 "use strict";1726 module.exports = function(exec) {1727 try {1728 return !!exec();1729 } catch (e) {1730 return true;1731 }1732 };1733 /***/1734 },1735 /* 17 */1736 /***/ function(module, exports, __w_pdfjs_require__) {1737 "use strict";1738 var isObject = __w_pdfjs_require__(13);1739 var document = __w_pdfjs_require__(8).document;1740 var is = isObject(document) && isObject(document.createElement);1741 module.exports = function(it) {1742 return is ? document.createElement(it) : {};1743 };1744 /***/1745 },1746 /* 18 */1747 /***/ function(module, exports, __w_pdfjs_require__) {1748 "use strict";1749 var isObject = __w_pdfjs_require__(13);1750 module.exports = function(it, S) {1751 if (!isObject(it)) return it;1752 var fn, val;1753 if (1754 S &&1755 typeof (fn = it.toString) == "function" &&1756 !isObject((val = fn.call(it)))1757 )1758 return val;1759 if (1760 typeof (fn = it.valueOf) == "function" &&1761 !isObject((val = fn.call(it)))1762 )1763 return val;1764 if (1765 !S &&1766 typeof (fn = it.toString) == "function" &&1767 !isObject((val = fn.call(it)))1768 )1769 return val;1770 throw TypeError("Can't convert object to primitive value");1771 };1772 /***/1773 },1774 /* 19 */1775 /***/ function(module, exports, __w_pdfjs_require__) {1776 "use strict";1777 module.exports = function(bitmap, value) {1778 return {1779 enumerable: !(bitmap & 1),1780 configurable: !(bitmap & 2),1781 writable: !(bitmap & 4),1782 value: value1783 };1784 };1785 /***/1786 },1787 /* 20 */1788 /***/ function(module, exports, __w_pdfjs_require__) {1789 "use strict";1790 var global = __w_pdfjs_require__(8);1791 var hide = __w_pdfjs_require__(10);1792 var has = __w_pdfjs_require__(21);1793 var SRC = __w_pdfjs_require__(22)("src");1794 var $toString = __w_pdfjs_require__(23);1795 var TO_STRING = "toString";1796 var TPL = ("" + $toString).split(TO_STRING);1797 __w_pdfjs_require__(9).inspectSource = function(it) {1798 return $toString.call(it);1799 };1800 (module.exports = function(O, key, val, safe) {1801 var isFunction = typeof val == "function";1802 if (isFunction) has(val, "name") || hide(val, "name", key);1803 if (O[key] === val) return;1804 if (isFunction)1805 has(val, SRC) ||1806 hide(val, SRC, O[key] ? "" + O[key] : TPL.join(String(key)));1807 if (O === global) {1808 O[key] = val;1809 } else if (!safe) {1810 delete O[key];1811 hide(O, key, val);1812 } else if (O[key]) {1813 O[key] = val;1814 } else {1815 hide(O, key, val);1816 }1817 })(Function.prototype, TO_STRING, function toString() {1818 return (1819 (typeof this == "function" && this[SRC]) || $toString.call(this)1820 );1821 });1822 /***/1823 },1824 /* 21 */1825 /***/ function(module, exports, __w_pdfjs_require__) {1826 "use strict";1827 var hasOwnProperty = {}.hasOwnProperty;1828 module.exports = function(it, key) {1829 return hasOwnProperty.call(it, key);1830 };1831 /***/1832 },1833 /* 22 */1834 /***/ function(module, exports, __w_pdfjs_require__) {1835 "use strict";1836 var id = 0;1837 var px = Math.random();1838 module.exports = function(key) {1839 return "Symbol(".concat(1840 key === undefined ? "" : key,1841 ")_",1842 (++id + px).toString(36)1843 );1844 };1845 /***/1846 },1847 /* 23 */1848 /***/ function(module, exports, __w_pdfjs_require__) {1849 "use strict";1850 module.exports = __w_pdfjs_require__(24)(1851 "native-function-to-string",1852 Function.toString1853 );1854 /***/1855 },1856 /* 24 */1857 /***/ function(module, exports, __w_pdfjs_require__) {1858 "use strict";1859 var core = __w_pdfjs_require__(9);1860 var global = __w_pdfjs_require__(8);1861 var SHARED = "__core-js_shared__";1862 var store = global[SHARED] || (global[SHARED] = {});1863 (module.exports = function(key, value) {1864 return store[key] || (store[key] = value !== undefined ? value : {});1865 })("versions", []).push({1866 version: core.version,1867 mode: __w_pdfjs_require__(25) ? "pure" : "global",1868 copyright: "© 2019 Denis Pushkarev (zloirock.ru)"1869 });1870 /***/1871 },1872 /* 25 */1873 /***/ function(module, exports, __w_pdfjs_require__) {1874 "use strict";1875 module.exports = false;1876 /***/1877 },1878 /* 26 */1879 /***/ function(module, exports, __w_pdfjs_require__) {1880 "use strict";1881 var aFunction = __w_pdfjs_require__(27);1882 module.exports = function(fn, that, length) {1883 aFunction(fn);1884 if (that === undefined) return fn;1885 switch (length) {1886 case 1:1887 return function(a) {1888 return fn.call(that, a);1889 };1890 case 2:1891 return function(a, b) {1892 return fn.call(that, a, b);1893 };1894 case 3:1895 return function(a, b, c) {1896 return fn.call(that, a, b, c);1897 };1898 }1899 return function() {1900 return fn.apply(that, arguments);1901 };1902 };1903 /***/1904 },1905 /* 27 */1906 /***/ function(module, exports, __w_pdfjs_require__) {1907 "use strict";1908 module.exports = function(it) {1909 if (typeof it != "function")1910 throw TypeError(it + " is not a function!");1911 return it;1912 };1913 /***/1914 },1915 /* 28 */1916 /***/ function(module, exports, __w_pdfjs_require__) {1917 "use strict";1918 var toInteger = __w_pdfjs_require__(29);1919 var min = Math.min;1920 module.exports = function(it) {1921 return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0;1922 };1923 /***/1924 },1925 /* 29 */1926 /***/ function(module, exports, __w_pdfjs_require__) {1927 "use strict";1928 var ceil = Math.ceil;1929 var floor = Math.floor;1930 module.exports = function(it) {1931 return isNaN((it = +it)) ? 0 : (it > 0 ? floor : ceil)(it);1932 };1933 /***/1934 },1935 /* 30 */1936 /***/ function(module, exports, __w_pdfjs_require__) {1937 "use strict";1938 var isRegExp = __w_pdfjs_require__(31);1939 var defined = __w_pdfjs_require__(34);1940 module.exports = function(that, searchString, NAME) {1941 if (isRegExp(searchString))1942 throw TypeError("String#" + NAME + " doesn't accept regex!");1943 return String(defined(that));1944 };1945 /***/1946 },1947 /* 31 */1948 /***/ function(module, exports, __w_pdfjs_require__) {1949 "use strict";1950 var isObject = __w_pdfjs_require__(13);1951 var cof = __w_pdfjs_require__(32);1952 var MATCH = __w_pdfjs_require__(33)("match");1953 module.exports = function(it) {1954 var isRegExp;1955 return (1956 isObject(it) &&1957 ((isRegExp = it[MATCH]) !== undefined1958 ? !!isRegExp1959 : cof(it) == "RegExp")1960 );1961 };1962 /***/1963 },1964 /* 32 */1965 /***/ function(module, exports, __w_pdfjs_require__) {1966 "use strict";1967 var toString = {}.toString;1968 module.exports = function(it) {1969 return toString.call(it).slice(8, -1);1970 };1971 /***/1972 },1973 /* 33 */1974 /***/ function(module, exports, __w_pdfjs_require__) {1975 "use strict";1976 var store = __w_pdfjs_require__(24)("wks");1977 var uid = __w_pdfjs_require__(22);1978 var _Symbol = __w_pdfjs_require__(8).Symbol;1979 var USE_SYMBOL = typeof _Symbol == "function";1980 var $exports = (module.exports = function(name) {1981 return (1982 store[name] ||1983 (store[name] =1984 (USE_SYMBOL && _Symbol[name]) ||1985 (USE_SYMBOL ? _Symbol : uid)("Symbol." + name))1986 );1987 });1988 $exports.store = store;1989 /***/1990 },1991 /* 34 */1992 /***/ function(module, exports, __w_pdfjs_require__) {...

Full Screen

Full Screen

svgView.js

Source:svgView.js Github

copy

Full Screen

...33/******/ 3: 034/******/ };35/******/36/******/ // The require function37/******/ function __w_pdfjs_require__(moduleId) {38/******/39/******/ // Check if module is in cache40/******/ if(installedModules[moduleId]) {41/******/ return installedModules[moduleId].exports;42/******/ }43/******/ // Create a new module (and put it into the cache)44/******/ var module = installedModules[moduleId] = {45/******/ i: moduleId,46/******/ l: false,47/******/ exports: {}48/******/ };49/******/50/******/ // Execute the module function51/******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);52/******/53/******/ // Flag the module as loaded54/******/ module.l = true;55/******/56/******/ // Return the exports of the module57/******/ return module.exports;58/******/ }59/******/60/******/ // This file contains only the entry chunk.61/******/ // The chunk loading function for additional chunks62/******/ __w_pdfjs_require__.e = function requireEnsure(chunkId) {63/******/ var installedChunkData = installedChunks[chunkId];64/******/ if(installedChunkData === 0) {65/******/ return new Promise(function(resolve) { resolve(); });66/******/ }67/******/68/******/ // a Promise means "currently loading".69/******/ if(installedChunkData) {70/******/ return installedChunkData[2];71/******/ }72/******/73/******/ // setup Promise in chunk cache74/******/ var promise = new Promise(function(resolve, reject) {75/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];76/******/ });77/******/ installedChunkData[2] = promise;78/******/79/******/ // start chunk loading80/******/ var head = document.getElementsByTagName('head')[0];81/******/ var script = document.createElement('script');82/******/ script.type = 'text/javascript';83/******/ script.charset = 'utf-8';84/******/ script.async = true;85/******/ script.timeout = 120000;86/******/87/******/ if (__w_pdfjs_require__.nc) {88/******/ script.setAttribute("nonce", __w_pdfjs_require__.nc);89/******/ }90/******/ script.src = __w_pdfjs_require__.p + "js/" + chunkId + ".svgView.js";91/******/ var timeout = setTimeout(onScriptComplete, 120000);92/******/ script.onerror = script.onload = onScriptComplete;93/******/ function onScriptComplete() {94/******/ // avoid mem leaks in IE.95/******/ script.onerror = script.onload = null;96/******/ clearTimeout(timeout);97/******/ var chunk = installedChunks[chunkId];98/******/ if(chunk !== 0) {99/******/ if(chunk) {100/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));101/******/ }102/******/ installedChunks[chunkId] = undefined;103/******/ }104/******/ };105/******/ head.appendChild(script);106/******/107/******/ return promise;108/******/ };109/******/110/******/ // expose the modules object (__webpack_modules__)111/******/ __w_pdfjs_require__.m = modules;112/******/113/******/ // expose the module cache114/******/ __w_pdfjs_require__.c = installedModules;115/******/116/******/ // identity function for calling harmony imports with the correct context117/******/ __w_pdfjs_require__.i = function(value) { return value; };118/******/119/******/ // define getter function for harmony exports120/******/ __w_pdfjs_require__.d = function(exports, name, getter) {121/******/ if(!__w_pdfjs_require__.o(exports, name)) {122/******/ Object.defineProperty(exports, name, {123/******/ configurable: false,124/******/ enumerable: true,125/******/ get: getter126/******/ });127/******/ }128/******/ };129/******/130/******/ // getDefaultExport function for compatibility with non-harmony modules131/******/ __w_pdfjs_require__.n = function(module) {132/******/ var getter = module && module.__esModule ?133/******/ function getDefault() { return module['default']; } :134/******/ function getModuleExports() { return module; };135/******/ __w_pdfjs_require__.d(getter, 'a', getter);136/******/ return getter;137/******/ };138/******/139/******/ // Object.prototype.hasOwnProperty.call140/******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };141/******/142/******/ // __webpack_public_path__143/******/ __w_pdfjs_require__.p = "";144/******/145/******/ // on error function for async loading146/******/ __w_pdfjs_require__.oe = function(err) { console.error(err); throw err; };147/******/148/******/ // Load entry module and return exports149/******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 3);150/******/ })151/************************************************************************/152/******/ ([153/* 0 */154/***/ (function(module, exports, __w_pdfjs_require__) {155"use strict";156module.exports = {157 import: function _import() {158 throw new Error("System.import cannot be used indirectly");159 }160};161/***/ }),162/* 1 */,163/* 2 */,164/* 3 */165/***/ (function(module, exports, __w_pdfjs_require__) {166"use strict";167/* WEBPACK VAR INJECTION */(function(System) {168var DEFAULT_SCALE = 1;169var query = document.location.href.replace(/^[^?]*(\?([^#]*))?(#.*)?/, '$2');170var queryParams = query ? JSON.parse('{' + query.split('&').map(function (a) {171 return a.split('=').map(decodeURIComponent).map(JSON.stringify).join(': ');172}).join(',') + '}') : {};173var url = queryParams.file || '1.pdf';174function renderDocument(pdf, svgLib) {175 var promise = Promise.resolve();176 for (var i = 1; i <= pdf.numPages; i++) {177 promise = promise.then(function (pageNum) {178 return pdf.getPage(pageNum).then(function (page) {179 var viewport = page.getViewport(DEFAULT_SCALE);180 var container = document.createElement('div');181 container.id = 'pageContainer' + pageNum;182 container.className = 'pageContainer';183 container.style.width = viewport.width + 'px';184 container.style.height = viewport.height + 'px';185 document.getElementById("main").appendChild(container);186 return page.getOperatorList().then(function (opList) {187 var svgGfx = new svgLib.SVGGraphics(page.commonObjs, page.objs);188 return svgGfx.getSVG(opList, viewport).then(function (svg) {189 container.appendChild(svg);190 });191 });192 });193 }.bind(null, i));194 }195}196 function renderDocumentNum(pdf, svgLib, pageNum) {197 return pdf.getPage(pageNum).then(function (page) {198 var viewport = page.getViewport(DEFAULT_SCALE);199 var container = document.createElement('div');200 container.id = 'pageContainer' + pageNum;201 container.className = 'pageContainer';202 container.style.width = viewport.width + 'px';203 container.style.height = viewport.height + 'px';204 document.getElementById("main").appendChild(container);205 return page.getOperatorList().then(function (opList) {206 var svgGfx = new svgLib.SVGGraphics(page.commonObjs, page.objs);207 return svgGfx.getSVG(opList, viewport).then(function (svg) {208 container.appendChild(svg);209 });210 });211 });212 }213 214Promise.all([__w_pdfjs_require__.e/* import() */(1).then(__w_pdfjs_require__.bind(null, 1)), __w_pdfjs_require__.e/* import() */(2).then(__w_pdfjs_require__.bind(null, 2)), __w_pdfjs_require__.e/* import() */(0).then(__w_pdfjs_require__.bind(null, 4))]).then(function (modules) {215 var api = modules[0],216 svg = modules[1],217 global = modules[2];218 global.PDFJS.workerSrc ='js/pdf.worker.js';219 global.PDFJS.cMapUrl = 'js/bcmaps/';220 global.PDFJS.cMapPacked = true;221 PDFSVG = svg;222 PDFAPI = api;223 //api.getDocument(url).then(function (doc) {224 // renderDocumentNum(doc, svg,1);225 //});226});227/* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(0)))228/***/ })229/******/ ]);230//# sourceMappingURL=svgView.js.map231function ShowPDFFile(Url, pageNum, progress) {232 pageNum = pageNum | 1;233 PDFURL = Url;234 PDFAPI.getDocument(Url, null, null, function (obj) {235 if (progress) progress(obj.loaded / obj.total);236 }).then(function (doc) {237 PDFDOC = doc;238 PDFCOUNT = doc.numPages;239 ShowPDFPage(pageNum, function () {240 if (AfterLoadPDF) AfterLoadPDF(pageNum);241 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var pdfjsLib = __w_pdfjs_require__('pdfjs-dist/build/pdf');2var pdfjsLib = __w_pdfjs_require__('pdfjs-dist/build/pdf');3var pdfjsLib = __w_pdfjs_require__('pdfjs-dist/build/pdf');4var pdfjsLib = __w_pdfjs_require__('pdfjs-dist/build/pdf');5var pdfjsLib = __w_pdfjs_require__('pdfjs-dist/build/pdf');6var pdfjsLib = __w_pdfjs_require__('pdfjs-dist/build/pdf');7var pdfjsLib = __w_pdfjs_require__('pdfjs-dist/build/pdf');8var pdfjsLib = __w_pdfjs_require__('pdfjs-dist/build/pdf');9var pdfjsLib = __w_pdfjs_require__('pdfjs-dist/build/pdf');10var pdfjsLib = __w_pdfjs_require__('pdfjs-dist/build/pdf');11var pdfjsLib = __w_pdfjs_require__('pdfjs-dist/build/pdf');12var pdfjsLib = __w_pdfjs_require__('pdfjs-dist/build/pdf');13var pdfjsLib = __w_pdfjs_require__('pdfjs-dist/build/pdf');

Full Screen

Using AI Code Generation

copy

Full Screen

1var pdfjsLib = __w_pdfjs_require__('pdfjs-dist/build/pdf');2pdfjsLib.GlobalWorkerOptions.workerSrc = __w_pdfjs_require__('pdfjs-dist/build/pdf.worker.entry').workerSrc;3loadingTask.promise.then(function(pdfDocument) {4 console.log('PDF loaded');5 var pageNumber = 1;6 pdfDocument.getPage(pageNumber).then(function(page) {7 console.log('Page loaded');8 var scale = 1.5;9 var viewport = page.getViewport({scale: scale});10 var canvas = document.getElementById('the-canvas');11 var context = canvas.getContext('2d');12 canvas.height = viewport.height;13 canvas.width = viewport.width;14 var renderContext = {15 };16 var renderTask = page.render(renderContext);17 renderTask.promise.then(function () {18 console.log('Page rendered');19 });20 });21}, function (reason) {22 console.error(reason);23});24var __w_pdfjs_require__ = (function() {25 var modules = {};26 var __w_pdfjs_require__ = function(name) {27 if (modules[name]) {28 return modules[name];29 }30 var module = {exports: {}};31 modules[name] = module.exports;32 pdfjsLibRoot[name].call(module.exports, module, module.exports, __w_pdfjs_require__);33 return module.exports;34 };35 return __w_pdfjs_require__;36})();37var pdfjsLibRoot = {38 'pdfjs-dist/build/pdf': function(module, exports, __w_pdfjs_require__) {39 module.exports = window['pdfjs-dist/build/pdf'];40 },41 'pdfjs-dist/build/pdf.worker.entry': function(module, exports, __w_pdfjs_require__) {42 module.exports = window['pdfjs-dist/build/pdf.worker.entry'];43 },44};45var canvas = document.getElementById('the-canvas');46var context = canvas.getContext('2d');47context.fillStyle = 'blue';48context.fillRect(10, 10, 200, 100);

Full Screen

Using AI Code Generation

copy

Full Screen

1var pdfjsLib = __w_pdfjs_require__('pdfjs-dist/build/pdf');2pdfjsLib.GlobalWorkerOptions.workerSrc = '/pdf.worker.js';3var loadingTask = pdfjsLib.getDocument('/pdf.pdf');4loadingTask.promise.then(function(pdf) {5 console.log('PDF loaded');6 var pageNumber = 1;7 pdf.getPage(pageNumber).then(function(page) {8 console.log('Page loaded');9 var scale = 1.5;10 var viewport = page.getViewport({scale: scale});11 var canvas = document.getElementById('the-canvas');12 var context = canvas.getContext('2d');13 canvas.height = viewport.height;14 canvas.width = viewport.width;15 var renderContext = {16 };17 var renderTask = page.render(renderContext);18 renderTask.promise.then(function () {19 console.log('Page rendered');20 });21 });22}, function (reason) {23 console.error(reason);24});25importScripts('/pdfjs-dist/build/pdf.worker.entry.js');26importScripts('/pdfjs-dist/build/pdf.worker.js');27(function (root, factory) {28 if (typeof define === 'function' && define.amd) {29 define('pdfjs-dist/build/pdf.worker', ['exports', 'pdfjs-dist/build/pdf'], factory);30 } else if (typeof exports !== 'undefined') {31 factory(exports, require('./pdf'));32 } else {33 factory((root.pdfjsDistBuildPdfWorker = {}), root.pdfjsDistBuildPdf);34 }35}(this, function (exports, pdfjsLib) {36var pdfjsWorker = pdfjsLib.PDFWorker;37exports.PDFWorker = pdfjsWorker;38}));39(function (root, factory) {40 if (typeof define === 'function' && define.amd) {41 define('pdfjs-dist/build/pdf', ['exports', 'pdfjs-dist/build/pdf.combined'], factory);42 } else if (typeof exports !== 'undefined') {43 factory(exports, require('./pdf.combined'));

Full Screen

Using AI Code Generation

copy

Full Screen

1var __w_pdfjs_require__ = function (name) {2 return window[name];3};4var __w_pdfjs_require__ = function (name) {5 return window[name];6};7var __w_pdfjs_require__ = function (name) {8 return window[name];9};10var __w_pdfjs_require__ = function (name) {11 return window[name];12};13var __w_pdfjs_require__ = function (name) {14 return window[name];15};16var __w_pdfjs_require__ = function (name) {17 return window[name];18};19var __w_pdfjs_require__ = function (name) {20 return window[name];21};22var __w_pdfjs_require__ = function (name) {23 return window[name];24};25var __w_pdfjs_require__ = function (name) {26 return window[name];27};28var __w_pdfjs_require__ = function (name) {29 return window[name];30};31var __w_pdfjs_require__ = function (name) {32 return window[name];33};34var __w_pdfjs_require__ = function (name) {35 return window[name];36};37var __w_pdfjs_require__ = function (name) {38 return window[name];39};40var __w_pdfjs_require__ = function (name) {41 return window[name];42};43var __w_pdfjs_require__ = function (name) {44 return window[name];45};46var __w_pdfjs_require__ = function (name) {47 return window[name];48};

Full Screen

Using AI Code Generation

copy

Full Screen

1const pdfjsLib = __w_pdfjs_require__('pdfjs-dist/build/pdf');2const pdfjsLib = __w_pdfjs_require__('pdfjs-dist/build/pdf');3const fs = require('fs');4const path = require('path');5const pdfPath = path.resolve(__dirname, 'compressed.tracemonkey-pldi-09.pdf');6const pdfDoc = await pdfjsLib.getDocument(url).promise;7const page = await pdfDoc.getPage(1);8const viewport = page.getViewport({scale: 1.0});9const canvas = document.createElement('canvas');10const context = canvas.getContext('2d');11canvas.height = viewport.height;12canvas.width = viewport.width;13const renderContext = {14};15const renderTask = page.render(renderContext);16await renderTask.promise;17const image = canvas.toDataURL();18let data = image.replace(/^data:image\/\w+;base64,/, "");19let buf = new Buffer(data, 'base64');20fs.writeFileSync('output.png', buf);21console.log('Image saved');22const pdfjsLib = __w_pdfjs_require__('pdfjs-dist/build/pdf');23const fs = require('fs');24const path = require('path');25const pdfPath = path.resolve(__dirname, 'compressed.tracemonkey-pldi-09.pdf');26const pdfDoc = await pdfjsLib.getDocument(url).promise;27const page = await pdfDoc.getPage(1);28const viewport = page.getViewport({scale: 1.0});29const canvas = document.createElement('canvas');30const context = canvas.getContext('2d');31canvas.height = viewport.height;32canvas.width = viewport.width;33const renderContext = {

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful