UNPKG

ngx-extended-pdf-viewer

Version:

Embedding PDF files in your Angular application. Highly configurable viewer including the toolbar, sidebar, and all the features you're used to.

1,334 lines (1,119 loc) 582 kB
/** * @licstart The following is the entire license notice for the * Javascript code in this page * * Copyright 2020 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * @licend The above is the entire license notice for the * Javascript code in this page */ /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // 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 require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 0); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; if (!HTMLCollection.prototype[Symbol.iterator]) { HTMLCollection.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator]; } (function () { if (typeof window.CustomEvent === "function") { return; } function CustomEvent(event, params) { params = params || { bubbles: false, cancelable: false, detail: null }; var evt = document.createEvent("CustomEvent"); evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); return evt; } window.CustomEvent = CustomEvent; })(); ; var pdfjsWebApp, pdfjsWebAppOptions; { pdfjsWebApp = __webpack_require__(1); pdfjsWebAppOptions = __webpack_require__(6); } ; { __webpack_require__(41); } ; { __webpack_require__(46); } function getViewerConfiguration() { return { appContainer: document.body, mainContainer: document.getElementById("viewerContainer"), viewerContainer: document.getElementById("viewer"), eventBus: null, toolbar: { container: document.getElementById("toolbarViewer"), numPages: document.getElementById("numPages"), pageNumber: document.getElementById("pageNumber"), scaleSelectContainer: document.getElementById("scaleSelectContainer"), scaleSelect: document.getElementById("scaleSelect"), customScaleOption: document.getElementById("customScaleOption"), previous: document.getElementById("previous"), next: document.getElementById("next"), zoomIn: document.getElementById("zoomIn"), zoomOut: document.getElementById("zoomOut"), viewFind: document.getElementById("viewFind"), openFile: document.getElementById("openFile"), print: document.getElementById("print"), presentationModeButton: document.getElementById("presentationMode"), download: document.getElementById("download"), viewBookmark: document.getElementById("viewBookmark") }, secondaryToolbar: { toolbar: document.getElementById("secondaryToolbar"), toggleButton: document.getElementById("secondaryToolbarToggle"), toolbarButtonContainer: document.getElementById("secondaryToolbarButtonContainer"), presentationModeButton: document.getElementById("secondaryPresentationMode"), openFileButton: document.getElementById("secondaryOpenFile"), printButton: document.getElementById("secondaryPrint"), downloadButton: document.getElementById("secondaryDownload"), viewBookmarkButton: document.getElementById("secondaryViewBookmark"), firstPageButton: document.getElementById("firstPage"), lastPageButton: document.getElementById("lastPage"), pageRotateCwButton: document.getElementById("pageRotateCw"), pageRotateCcwButton: document.getElementById("pageRotateCcw"), cursorSelectToolButton: document.getElementById("cursorSelectTool"), cursorHandToolButton: document.getElementById("cursorHandTool"), scrollVerticalButton: document.getElementById("scrollVertical"), scrollHorizontalButton: document.getElementById("scrollHorizontal"), scrollWrappedButton: document.getElementById("scrollWrapped"), spreadNoneButton: document.getElementById("spreadNone"), spreadOddButton: document.getElementById("spreadOdd"), spreadEvenButton: document.getElementById("spreadEven"), documentPropertiesButton: document.getElementById("documentProperties") }, fullscreen: { contextFirstPage: document.getElementById("contextFirstPage"), contextLastPage: document.getElementById("contextLastPage"), contextPageRotateCw: document.getElementById("contextPageRotateCw"), contextPageRotateCcw: document.getElementById("contextPageRotateCcw") }, sidebar: { outerContainer: document.getElementById("outerContainer"), viewerContainer: document.getElementById("viewerContainer"), toggleButton: document.getElementById("sidebarToggle"), thumbnailButton: document.getElementById("viewThumbnail"), outlineButton: document.getElementById("viewOutline"), attachmentsButton: document.getElementById("viewAttachments"), layersButton: document.getElementById("viewLayers"), thumbnailView: document.getElementById("thumbnailView"), outlineView: document.getElementById("outlineView"), attachmentsView: document.getElementById("attachmentsView"), layersView: document.getElementById("layersView") }, sidebarResizer: { outerContainer: document.getElementById("outerContainer"), resizer: document.getElementById("sidebarResizer") }, findBar: { bar: document.getElementById("findbar"), toggleButton: document.getElementById("viewFind"), findField: document.getElementById("findInput"), findFieldMultiline: document.getElementById("findInputMultiline"), highlightAllCheckbox: document.getElementById("findHighlightAll"), caseSensitiveCheckbox: document.getElementById("findMatchCase"), entireWordCheckbox: document.getElementById("findEntireWord"), findMultipleSearchTextsCheckbox: document.getElementById("findMultipleSearchTexts"), ignoreAccentsCheckbox: document.getElementById("findIgnoreAccents"), fuzzyCheckbox: document.getElementById("findFuzzy"), findMsg: document.getElementById("findMsg"), findResultsCount: document.getElementById("findResultsCount"), findPreviousButton: document.getElementById("findPrevious"), findNextButton: document.getElementById("findNext") }, passwordOverlay: { overlayName: "passwordOverlay", container: document.getElementById("passwordOverlay"), label: document.getElementById("passwordText"), input: document.getElementById("password"), submitButton: document.getElementById("passwordSubmit"), cancelButton: document.getElementById("passwordCancel") }, documentProperties: { overlayName: "documentPropertiesOverlay", container: document.getElementById("documentPropertiesOverlay"), closeButton: document.getElementById("documentPropertiesClose"), fields: { fileName: document.getElementById("fileNameField"), fileSize: document.getElementById("fileSizeField"), title: document.getElementById("titleField"), author: document.getElementById("authorField"), subject: document.getElementById("subjectField"), keywords: document.getElementById("keywordsField"), creationDate: document.getElementById("creationDateField"), modificationDate: document.getElementById("modificationDateField"), creator: document.getElementById("creatorField"), producer: document.getElementById("producerField"), version: document.getElementById("versionField"), pageCount: document.getElementById("pageCountField"), pageSize: document.getElementById("pageSizeField"), linearized: document.getElementById("linearizedField") } }, errorWrapper: { container: document.getElementById("errorWrapper"), errorMessage: document.getElementById("errorMessage"), closeButton: document.getElementById("errorClose"), errorMoreInfo: document.getElementById("errorMoreInfo"), moreInfoButton: document.getElementById("errorShowMore"), lessInfoButton: document.getElementById("errorShowLess") }, printContainer: document.getElementById("printContainer"), openFileInputName: "fileInput", debuggerScriptPath: "./debugger.js" }; } function webViewerLoad() { var config = getViewerConfiguration(); window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication; window.PDFViewerApplicationOptions = pdfjsWebAppOptions.AppOptions; var event = document.createEvent("CustomEvent"); event.initCustomEvent("webviewerloaded", true, true, { source: window }); try { parent.document.dispatchEvent(event); } catch (ex) { console.error("webviewerloaded: ".concat(ex)); document.dispatchEvent(event); } pdfjsWebApp.PDFViewerApplication.run(config); } { window.webViewerLoad = webViewerLoad; } /***/ }), /* 1 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = void 0; var _regenerator = _interopRequireDefault(__webpack_require__(2)); var _ui_utils = __webpack_require__(5); var _app_options = __webpack_require__(6); var _pdfjsLib = __webpack_require__(8); var _pdf_cursor_tools = __webpack_require__(9); var _pdf_rendering_queue = __webpack_require__(11); var _pdf_sidebar = __webpack_require__(12); var _overlay_manager = __webpack_require__(13); var _password_prompt = __webpack_require__(14); var _pdf_attachment_viewer = __webpack_require__(15); var _pdf_document_properties = __webpack_require__(17); var _pdf_find_bar = __webpack_require__(18); var _pdf_find_controller = __webpack_require__(19); var _pdf_history = __webpack_require__(23); var _pdf_layer_viewer = __webpack_require__(24); var _pdf_link_service = __webpack_require__(25); var _pdf_outline_viewer = __webpack_require__(26); var _pdf_presentation_mode = __webpack_require__(27); var _pdf_sidebar_resizer = __webpack_require__(28); var _pdf_thumbnail_viewer = __webpack_require__(29); var _pdf_viewer = __webpack_require__(31); var _secondary_toolbar = __webpack_require__(37); var _toolbar = __webpack_require__(39); var _viewer_compatibility = __webpack_require__(7); var _view_history = __webpack_require__(40); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function _readOnlyError(name) { throw new Error("\"" + name + "\" is read-only"); } function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var DEFAULT_SCALE_DELTA = 1.1; var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000; var FORCE_PAGES_LOADED_TIMEOUT = 10000; var WHEEL_ZOOM_DISABLED_TIMEOUT = 1000; var ENABLE_PERMISSIONS_CLASS = "enablePermissions"; var ViewOnLoad = { UNKNOWN: -1, PREVIOUS: 0, INITIAL: 1 }; var KNOWN_VERSIONS = ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "2.0", "2.1", "2.2", "2.3"]; var KNOWN_GENERATORS = ["acrobat distiller", "acrobat pdfwriter", "adobe livecycle", "adobe pdf library", "adobe photoshop", "ghostscript", "tcpdf", "cairo", "dvipdfm", "dvips", "pdftex", "pdfkit", "itext", "prince", "quarkxpress", "mac os x", "microsoft", "openoffice", "oracle", "luradocument", "pdf-xchange", "antenna house", "aspose.cells", "fpdf"]; var DefaultExternalServices = /*#__PURE__*/function () { function DefaultExternalServices() { _classCallCheck(this, DefaultExternalServices); throw new Error("Cannot initialize DefaultExternalServices."); } _createClass(DefaultExternalServices, null, [{ key: "updateFindControlState", value: function updateFindControlState(data) {} }, { key: "updateFindMatchesCount", value: function updateFindMatchesCount(data) {} }, { key: "initPassiveLoading", value: function initPassiveLoading(callbacks) {} }, { key: "fallback", value: function fallback(data, callback) {} }, { key: "reportTelemetry", value: function reportTelemetry(data) {} }, { key: "createDownloadManager", value: function createDownloadManager(options) { throw new Error("Not implemented: createDownloadManager"); } }, { key: "createPreferences", value: function createPreferences() { throw new Error("Not implemented: createPreferences"); } }, { key: "createL10n", value: function createL10n(options) { throw new Error("Not implemented: createL10n"); } }, { key: "supportsIntegratedFind", get: function get() { return (0, _pdfjsLib.shadow)(this, "supportsIntegratedFind", false); } }, { key: "supportsDocumentFonts", get: function get() { return (0, _pdfjsLib.shadow)(this, "supportsDocumentFonts", true); } }, { key: "supportedMouseWheelZoomModifierKeys", get: function get() { return (0, _pdfjsLib.shadow)(this, "supportedMouseWheelZoomModifierKeys", { ctrlKey: true, metaKey: true }); } }, { key: "isInAutomation", get: function get() { return (0, _pdfjsLib.shadow)(this, "isInAutomation", false); } }]); return DefaultExternalServices; }(); exports.DefaultExternalServices = DefaultExternalServices; var PDFViewerApplication = { initialBookmark: document.location.hash.substring(1), _initializedCapability: (0, _pdfjsLib.createPromiseCapability)(), fellback: false, appConfig: null, pdfDocument: null, pdfLoadingTask: null, printService: null, pdfViewer: null, pdfThumbnailViewer: null, pdfRenderingQueue: null, pdfPresentationMode: null, pdfDocumentProperties: null, pdfLinkService: null, pdfHistory: null, pdfSidebar: null, pdfSidebarResizer: null, pdfOutlineViewer: null, pdfAttachmentViewer: null, pdfLayerViewer: null, pdfCursorTools: null, store: null, downloadManager: null, overlayManager: null, preferences: null, toolbar: null, secondaryToolbar: null, eventBus: null, l10n: null, isInitialViewSet: false, downloadComplete: false, isViewerEmbedded: window.parent !== window, url: "", baseUrl: "", externalServices: DefaultExternalServices, _boundEvents: {}, contentDispositionFilename: null, triggerDelayedFallback: null, _saveInProgress: false, _wheelUnusedTicks: 0, initialize: function initialize(appConfig) { var _this = this; return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() { var appContainer; return _regenerator["default"].wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _this.preferences = _this.externalServices.createPreferences(); _this.appConfig = appConfig; _context.next = 4; return _this._readPreferences(); case 4: _context.next = 6; return _this._parseHashParameters(); case 6: _context.next = 8; return _this._initializeL10n(); case 8: if (_this.isViewerEmbedded && _app_options.AppOptions.get("externalLinkTarget") === _pdfjsLib.LinkTarget.NONE) { _app_options.AppOptions.set("externalLinkTarget", _pdfjsLib.LinkTarget.TOP); } _context.next = 11; return _this._initializeViewerComponents(); case 11: _this.bindEvents(); _this.bindWindowEvents(); appContainer = appConfig.appContainer || document.documentElement; _this.l10n.translate(appContainer).then(function () { _this.eventBus.dispatch("localized", { source: _this }); }); _this._initializedCapability.resolve(); case 16: case "end": return _context.stop(); } } }, _callee); }))(); }, _readPreferences: function _readPreferences() { var _this2 = this; return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() { var prefs, name; return _regenerator["default"].wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: if (!_app_options.AppOptions.get("disablePreferences")) { _context2.next = 2; break; } return _context2.abrupt("return"); case 2: _context2.prev = 2; _context2.next = 5; return _this2.preferences.getAll(); case 5: prefs = _context2.sent; for (name in prefs) { _app_options.AppOptions.set(name, prefs[name]); } _context2.next = 12; break; case 9: _context2.prev = 9; _context2.t0 = _context2["catch"](2); console.error("_readPreferences: \"".concat(_context2.t0.message, "\".")); case 12: case "end": return _context2.stop(); } } }, _callee2, null, [[2, 9]]); }))(); }, _parseHashParameters: function _parseHashParameters() { var _this3 = this; return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() { var hash, hashParams, waitOn, viewer, enabled; return _regenerator["default"].wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: if (_app_options.AppOptions.get("pdfBugEnabled")) { _context3.next = 2; break; } return _context3.abrupt("return", undefined); case 2: hash = document.location.hash.substring(1); if (hash) { _context3.next = 5; break; } return _context3.abrupt("return", undefined); case 5: hashParams = (0, _ui_utils.parseQueryString)(hash), waitOn = []; if ("disableworker" in hashParams && hashParams.disableworker === "true") { waitOn.push(loadFakeWorker()); } if ("disablerange" in hashParams) { _app_options.AppOptions.set("disableRange", hashParams.disablerange === "true"); } if ("disablestream" in hashParams) { _app_options.AppOptions.set("disableStream", hashParams.disablestream === "true"); } if ("disableautofetch" in hashParams) { _app_options.AppOptions.set("disableAutoFetch", hashParams.disableautofetch === "true"); } if ("disablefontface" in hashParams) { _app_options.AppOptions.set("disableFontFace", hashParams.disablefontface === "true"); } if ("disablehistory" in hashParams) { _app_options.AppOptions.set("disableHistory", hashParams.disablehistory === "true"); } if ("webgl" in hashParams) { _app_options.AppOptions.set("enableWebGL", hashParams.webgl === "true"); } if ("removepageborders" in hashParams) { _app_options.AppOptions.set("removePageBorders", hashParams["removepageborders"] === "true"); } if ("verbosity" in hashParams) { _app_options.AppOptions.set("verbosity", hashParams.verbosity | 0); } if (!("textlayer" in hashParams)) { _context3.next = 24; break; } _context3.t0 = hashParams.textlayer; _context3.next = _context3.t0 === "off" ? 19 : _context3.t0 === "visible" ? 21 : _context3.t0 === "shadow" ? 21 : _context3.t0 === "hover" ? 21 : 24; break; case 19: _app_options.AppOptions.set("textLayerMode", _ui_utils.TextLayerMode.DISABLE); return _context3.abrupt("break", 24); case 21: viewer = _this3.appConfig.viewerContainer; viewer.classList.add("textLayer-" + hashParams.textlayer); return _context3.abrupt("break", 24); case 24: if ("pdfbug" in hashParams) { _app_options.AppOptions.set("pdfBug", true); _app_options.AppOptions.set("fontExtraProperties", true); enabled = hashParams.pdfbug.split(","); waitOn.push(loadAndEnablePDFBug(enabled)); } if ("locale" in hashParams) { _app_options.AppOptions.set("locale", hashParams.locale); } return _context3.abrupt("return", Promise.all(waitOn)["catch"](function (reason) { console.error("_parseHashParameters: \"".concat(reason.message, "\".")); })); case 27: case "end": return _context3.stop(); } } }, _callee3); }))(); }, _initializeL10n: function _initializeL10n() { var _this4 = this; return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() { var dir; return _regenerator["default"].wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: _this4.l10n = _this4.externalServices.createL10n({ locale: _app_options.AppOptions.get("locale") }); _context4.next = 3; return _this4.l10n.getDirection(); case 3: dir = _context4.sent; document.getElementsByTagName("html")[0].dir = dir; case 5: case "end": return _context4.stop(); } } }, _callee4); }))(); }, _initializeViewerComponents: function _initializeViewerComponents() { var _this5 = this; return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5() { var appConfig, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, container, viewer; return _regenerator["default"].wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: appConfig = _this5.appConfig; eventBus = appConfig.eventBus || new _ui_utils.EventBus({ isInAutomation: _this5.externalServices.isInAutomation }); _this5.eventBus = eventBus; _this5.overlayManager = new _overlay_manager.OverlayManager(); pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue(); pdfRenderingQueue.onIdle = _this5.cleanup.bind(_this5); _this5.pdfRenderingQueue = pdfRenderingQueue; pdfLinkService = new _pdf_link_service.PDFLinkService({ eventBus: eventBus, externalLinkTarget: _app_options.AppOptions.get("externalLinkTarget"), externalLinkRel: _app_options.AppOptions.get("externalLinkRel"), ignoreDestinationZoom: _app_options.AppOptions.get("ignoreDestinationZoom") }); _this5.pdfLinkService = pdfLinkService; downloadManager = _this5.externalServices.createDownloadManager(); _this5.downloadManager = downloadManager; findController = new _pdf_find_controller.PDFFindController({ linkService: pdfLinkService, eventBus: eventBus }); _this5.findController = findController; container = appConfig.mainContainer; viewer = appConfig.viewerContainer; _this5.pdfViewer = new _pdf_viewer.PDFViewer({ container: container, viewer: viewer, eventBus: eventBus, renderingQueue: pdfRenderingQueue, linkService: pdfLinkService, downloadManager: downloadManager, findController: findController, renderer: _app_options.AppOptions.get("renderer"), enableWebGL: _app_options.AppOptions.get("enableWebGL"), l10n: _this5.l10n, textLayerMode: _app_options.AppOptions.get("textLayerMode"), imageResourcesPath: _app_options.AppOptions.get("imageResourcesPath"), removePageBorders: _app_options.AppOptions.get("removePageBorders"), renderInteractiveForms: _app_options.AppOptions.get("renderInteractiveForms"), enablePrintAutoRotate: _app_options.AppOptions.get("enablePrintAutoRotate"), useOnlyCssZoom: _app_options.AppOptions.get("useOnlyCssZoom"), maxCanvasPixels: _app_options.AppOptions.get("maxCanvasPixels") }); pdfRenderingQueue.setViewer(_this5.pdfViewer); pdfLinkService.setViewer(_this5.pdfViewer); _this5.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({ container: appConfig.sidebar.thumbnailView, eventBus: eventBus, renderingQueue: pdfRenderingQueue, linkService: pdfLinkService, l10n: _this5.l10n }); pdfRenderingQueue.setThumbnailViewer(_this5.pdfThumbnailViewer); _this5.pdfHistory = new _pdf_history.PDFHistory({ linkService: pdfLinkService, eventBus: eventBus }); pdfLinkService.setHistory(_this5.pdfHistory); if (!_this5.supportsIntegratedFind) { _this5.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, _this5.l10n); } _this5.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, _this5.overlayManager, eventBus, _this5.l10n); _this5.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({ container: container, eventBus: eventBus, cursorToolOnLoad: _app_options.AppOptions.get("cursorToolOnLoad") }); _this5.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, _this5.l10n); _this5.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus); if (_this5.supportsFullscreen) { _this5.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({ container: container, pdfViewer: _this5.pdfViewer, eventBus: eventBus, contextMenuItems: appConfig.fullscreen }); } _this5.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, _this5.overlayManager, _this5.l10n); _this5.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({ container: appConfig.sidebar.outlineView, eventBus: eventBus, linkService: pdfLinkService }); _this5.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({ container: appConfig.sidebar.attachmentsView, eventBus: eventBus, downloadManager: downloadManager }); _this5.pdfLayerViewer = new _pdf_layer_viewer.PDFLayerViewer({ container: appConfig.sidebar.layersView, eventBus: eventBus, l10n: _this5.l10n }); _this5.pdfSidebar = new _pdf_sidebar.PDFSidebar({ elements: appConfig.sidebar, pdfViewer: _this5.pdfViewer, pdfThumbnailViewer: _this5.pdfThumbnailViewer, eventBus: eventBus, l10n: _this5.l10n }); _this5.pdfSidebar.onToggled = _this5.forceRendering.bind(_this5); _this5.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, _this5.l10n); case 35: case "end": return _context5.stop(); } } }, _callee5); }))(); }, run: function run(config) { this.initialize(config).then(webViewerInitialized); }, get initialized() { return this._initializedCapability.settled; }, get initializedPromise() { return this._initializedCapability.promise; }, zoomIn: function zoomIn(ticks) { if (this.pdfViewer.isInPresentationMode) { return; } var newScale = this.pdfViewer.currentScale; var maxScale = Number(_app_options.AppOptions.get("maxZoom")); if (!maxScale) { maxScale = (_readOnlyError("maxScale"), _ui_utils.MAX_SCALE); } do { newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2); newScale = Math.ceil(newScale * 10) / 10; newScale = Math.min(maxScale, newScale); } while (--ticks > 0 && newScale < maxScale); this.pdfViewer.currentScaleValue = newScale; }, zoomOut: function zoomOut(ticks) { if (this.pdfViewer.isInPresentationMode) { return; } var newScale = this.pdfViewer.currentScale; var minScale = Number(_app_options.AppOptions.get("minZoom")); if (!minScale) { minScale = (_readOnlyError("minScale"), _ui_utils.MIN_SCALE); } do { newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2); newScale = Math.floor(newScale * 10) / 10; newScale = Math.max(minScale, newScale); } while (--ticks > 0 && newScale > minScale); this.pdfViewer.currentScaleValue = newScale; }, zoomReset: function zoomReset() { if (this.pdfViewer.isInPresentationMode) { return; } this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE; }, get pagesCount() { return this.pdfDocument ? this.pdfDocument.numPages : 0; }, get page() { return this.pdfViewer.currentPageNumber; }, set page(val) { this.pdfViewer.currentPageNumber = val; }, get printing() { return !!this.printService; }, get supportsPrinting() { return PDFPrintServiceFactory.instance.supportsPrinting; }, get supportsFullscreen() { var support; var doc = document.documentElement; support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen); if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) { support = false; } return (0, _pdfjsLib.shadow)(this, "supportsFullscreen", support); }, get supportsIntegratedFind() { return this.externalServices.supportsIntegratedFind; }, get supportsDocumentFonts() { return this.externalServices.supportsDocumentFonts; }, get loadingBar() { var bar = new _ui_utils.ProgressBar("#loadingBar"); return (0, _pdfjsLib.shadow)(this, "loadingBar", bar); }, get supportedMouseWheelZoomModifierKeys() { return this.externalServices.supportedMouseWheelZoomModifierKeys; }, initPassiveLoading: function initPassiveLoading() { throw new Error("Not implemented: initPassiveLoading"); }, setTitleUsingUrl: function setTitleUsingUrl() { var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ""; this.url = url; this.baseUrl = url.split("#")[0]; var title = (0, _ui_utils.getPDFFileNameFromURL)(url, ""); if (!title) { try { title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url; } catch (ex) { title = url; } } this.setTitle(title); }, setTitle: function setTitle(title) { if (this.isViewerEmbedded) { return; } document.title = title; }, close: function close() { var _this6 = this; return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6() { var errorWrapper, promise; return _regenerator["default"].wrap(function _callee6$(_context6) { while (1) { switch (_context6.prev = _context6.next) { case 0: errorWrapper = _this6.appConfig.errorWrapper.container; errorWrapper.setAttribute("hidden", "true"); if (_this6.pdfLoadingTask) { _context6.next = 4; break; } return _context6.abrupt("return", undefined); case 4: promise = _this6.pdfLoadingTask.destroy(); _this6.pdfLoadingTask = null; if (_this6.pdfDocument) { _this6.pdfDocument = null; _this6.pdfThumbnailViewer.setDocument(null); _this6.pdfViewer.setDocument(null); _this6.pdfLinkService.setDocument(null); _this6.pdfDocumentProperties.setDocument(null); } webViewerResetPermissions(); _this6.store = null; _this6.isInitialViewSet = false; _this6.downloadComplete = false; _this6.url = ""; _this6.baseUrl = ""; _this6.contentDispositionFilename = null; _this6.triggerDelayedFallback = null; _this6._saveInProgress = false; _this6.pdfSidebar.reset(); _this6.pdfOutlineViewer.reset(); _this6.pdfAttachmentViewer.reset(); _this6.pdfLayerViewer.reset(); if (_this6.pdfHistory) { _this6.pdfHistory.reset(); } if (_this6.findBar) { _this6.findBar.reset(); } _this6.toolbar.reset(); _this6.secondaryToolbar.reset(); if (typeof PDFBug !== "undefined") { PDFBug.cleanup(); } return _context6.abrupt("return", promise); case 26: case "end": return _context6.stop(); } } }, _callee6); }))(); }, open: function open(file, args) { var _this7 = this; return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee7() { var workerParameters, key, parameters, apiParameters, _key, value, _key2, _value, loadingTask; return _regenerator["default"].wrap(function _callee7$(_context7) { while (1) { switch (_context7.prev = _context7.next) { case 0: if (!_this7.pdfLoadingTask) { _context7.next = 3; break; } _context7.next = 3; return _this7.close(); case 3: workerParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.WORKER); for (key in workerParameters) { _pdfjsLib.GlobalWorkerOptions[key] = workerParameters[key]; } parameters = Object.create(null); if (typeof file === "string") { _this7.setTitleUsingUrl(file); parameters.url = file; } else if (file && "byteLength" in file) { parameters.data = file; } else if (file.url && file.originalUrl) { _this7.setTitleUsingUrl(file.originalUrl); parameters.url = file.url; } apiParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.API); for (_key in apiParameters) { value = apiParameters[_key]; if (_key === "docBaseUrl" && !value) {} parameters[_key] = value; } if (args) { for (_key2 in args) { _value = args[_key2]; if (_key2 === "length") { _this7.pdfDocumentProperties.setFileSize(_value); } parameters[_key2] = _value; } } loadingTask = (0, _pdfjsLib.getDocument)(parameters); _this7.pdfLoadingTask = loadingTask; loadingTask.onPassword = function (updateCallback, reason) { _this7.pdfLinkService.externalLinkEnabled = false; _this7.passwordPrompt.setUpdateCallback(updateCallback, reason); _this7.passwordPrompt.open(); }; loadingTask.onProgress = function (_ref) { var loaded = _ref.loaded, total = _ref.total; _this7.progress(loaded / total); }; loadingTask.onUnsupportedFeature = _this7.fallback.bind(_this7); return _context7.abrupt("return", loadingTask.promise.then(function (pdfDocument) { _this7.load(pdfDocument); }, function (exception) { if (loadingTask !== _this7.pdfLoadingTask) { return undefined; } var message = exception && exception.message; var loadingErrorMessage; if (exception instanceof _pdfjsLib.InvalidPDFException) { loadingErrorMessage = _this7.l10n.get("invalid_file_error", null, "Invalid or corrupted PDF file."); } else if (exception instanceof _pdfjsLib.MissingPDFException) { loadingErrorMessage = _this7.l10n.get("missing_file_error", null, "Missing PDF file."); } else if (exception instanceof _pdfjsLib.UnexpectedResponseException) { loadingErrorMessage = _this7.l10n.get("unexpected_response_error", null, "Unexpected server response."); } else { loadingErrorMessage = _this7.l10n.get("loading_error", null, "An error occurred while loading the PDF."); } return loadingErrorMessage.then(function (msg) { _this7.error(msg, { message: message }); _this7.onError(exception); throw exception; }); })); case 16: case "end": return _context7.stop(); } } }, _callee7); }))(); }, download: function download() { var _this8 = this; var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, _ref2$sourceEventType = _ref2.sourceEventType, sourceEventType = _ref2$sourceEventType === void 0 ? "download" : _ref2$sourceEventType; function downloadByUrl() { downloadManager.downloadUrl(url, filename); } var url = this.baseUrl; var filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url); var downloadManager = this.downloadManager; downloadManager.onerror = function (err) { _this8.error("PDF failed to download: ".concat(err)); }; if (!this.pdfDocument || !this.downloadComplete) { downloadByUrl(); return; } this.pdfDocument.getData().then(function (data) { var blob = new Blob([data], { type: "application/pdf" }); downloadManager.download(blob, url, filename, sourceEventType); })["catch"](downloadByUrl); }, save: function save() { var _this9 = this; var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, _ref3$sourceEventType = _ref3.sourceEventType, sourceEventType = _ref3$sourceEventType === void 0 ? "download" : _ref3$sourceEventType; if (this._saveInProgress) { return; } var url = this.baseUrl; var filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url); var downloadManager = this.downloadManager; downloadManager.onerror = function (err) { _this9.error("PDF failed to be saved: ".concat(err)); }; if (!this.pdfDocument || !this.downloadComplete) { this.download({ sourceEventType: sourceEventType }); return; } this._saveInProgress = true; this.pdfDocument.saveDocument(this.pdfDocument.annotationStorage).then(function (data) { var blob = new Blob([data], { type: "application/pdf" }); downloadManager.download(blob, url, filename, sourceEventType); })["catch"](function (error) { console.log("Error during the download:"); console.log(error); _this9.download({ sourceEventType: sourceEventType }); })["finally"](function () { _this9._saveInProgress = false; }); }, _delayedFallback: function _delayedFallback(featureId) { var _this10 = this; this.externalServices.reportTelemetry({ type: "unsupportedFeature", featureId: featureId }); if (!this.triggerDelayedFallback) { this.triggerDelayedFallback = function () { _this10.fallback(featureId); _this10.triggerDelayedFallback = null; }; } }, fallback: function fallback(featureId) { this.externalServices.reportTelemetry({ type: "unsupportedFeature", featureId: featureId }); if (this.fellback) { return; } this.fellback = true; this.externalServices.fallback({ featureId: featureId, url: this.baseUrl }, function response(download) { if (!download) { return; } PDFViewerApplication.download({ sourceEventType: "download" }); }); }, error: function error(message, moreInfo) { var moreInfoText = [this.l10n.get("error_version_info", { version: _pdfjsLib.version || "?", build: _pdfjsLib.build || "?" }, "PDF.js v{{version}} (build: {{build}})")]; if (moreInfo) { moreInfoText.push(this.l10n.get("error_message", { message: moreInfo.message }, "Message: {{message}}")); if (moreInfo.stack) { moreInfoText.push(this.l10n.get("error_stack", { s