2
0

app.js 78 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2019 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. "use strict";
  23. Object.defineProperty(exports, "__esModule", {
  24. value: true
  25. });
  26. exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = void 0;
  27. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  28. var _ui_utils = require("./ui_utils");
  29. var _app_options = require("./app_options");
  30. var _pdf = require("../pdf");
  31. var _pdf_cursor_tools = require("./pdf_cursor_tools");
  32. var _pdf_rendering_queue = require("./pdf_rendering_queue");
  33. var _pdf_sidebar = require("./pdf_sidebar");
  34. var _overlay_manager = require("./overlay_manager");
  35. var _password_prompt = require("./password_prompt");
  36. var _pdf_attachment_viewer = require("./pdf_attachment_viewer");
  37. var _pdf_document_properties = require("./pdf_document_properties");
  38. var _pdf_find_bar = require("./pdf_find_bar");
  39. var _pdf_find_controller = require("./pdf_find_controller");
  40. var _pdf_history = require("./pdf_history");
  41. var _pdf_link_service = require("./pdf_link_service");
  42. var _pdf_outline_viewer = require("./pdf_outline_viewer");
  43. var _pdf_presentation_mode = require("./pdf_presentation_mode");
  44. var _pdf_sidebar_resizer = require("./pdf_sidebar_resizer");
  45. var _pdf_thumbnail_viewer = require("./pdf_thumbnail_viewer");
  46. var _pdf_viewer = require("./pdf_viewer");
  47. var _secondary_toolbar = require("./secondary_toolbar");
  48. var _toolbar = require("./toolbar");
  49. var _view_history = require("./view_history");
  50. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  51. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  52. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  53. function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { 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; }
  54. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  55. 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); } }
  56. 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); }); }; }
  57. var DEFAULT_SCALE_DELTA = 1.1;
  58. var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
  59. var FORCE_PAGES_LOADED_TIMEOUT = 10000;
  60. var WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  61. var ViewOnLoad = {
  62. UNKNOWN: -1,
  63. PREVIOUS: 0,
  64. INITIAL: 1
  65. };
  66. var DefaultExternalServices = {
  67. updateFindControlState: function updateFindControlState(data) {},
  68. updateFindMatchesCount: function updateFindMatchesCount(data) {},
  69. initPassiveLoading: function initPassiveLoading(callbacks) {},
  70. fallback: function fallback(data, callback) {},
  71. reportTelemetry: function reportTelemetry(data) {},
  72. createDownloadManager: function createDownloadManager(options) {
  73. throw new Error('Not implemented: createDownloadManager');
  74. },
  75. createPreferences: function createPreferences() {
  76. throw new Error('Not implemented: createPreferences');
  77. },
  78. createL10n: function createL10n(options) {
  79. throw new Error('Not implemented: createL10n');
  80. },
  81. supportsIntegratedFind: false,
  82. supportsDocumentFonts: true,
  83. supportsDocumentColors: true,
  84. supportedMouseWheelZoomModifierKeys: {
  85. ctrlKey: true,
  86. metaKey: true
  87. }
  88. };
  89. exports.DefaultExternalServices = DefaultExternalServices;
  90. var PDFViewerApplication = {
  91. initialBookmark: document.location.hash.substring(1),
  92. initialized: false,
  93. fellback: false,
  94. appConfig: null,
  95. pdfDocument: null,
  96. pdfLoadingTask: null,
  97. printService: null,
  98. pdfViewer: null,
  99. pdfThumbnailViewer: null,
  100. pdfRenderingQueue: null,
  101. pdfPresentationMode: null,
  102. pdfDocumentProperties: null,
  103. pdfLinkService: null,
  104. pdfHistory: null,
  105. pdfSidebar: null,
  106. pdfSidebarResizer: null,
  107. pdfOutlineViewer: null,
  108. pdfAttachmentViewer: null,
  109. pdfCursorTools: null,
  110. store: null,
  111. downloadManager: null,
  112. overlayManager: null,
  113. preferences: null,
  114. toolbar: null,
  115. secondaryToolbar: null,
  116. eventBus: null,
  117. l10n: null,
  118. isInitialViewSet: false,
  119. downloadComplete: false,
  120. isViewerEmbedded: window.parent !== window,
  121. url: '',
  122. baseUrl: '',
  123. externalServices: DefaultExternalServices,
  124. _boundEvents: {},
  125. contentDispositionFilename: null,
  126. initialize: function () {
  127. var _initialize = _asyncToGenerator(
  128. /*#__PURE__*/
  129. _regenerator["default"].mark(function _callee(appConfig) {
  130. var _this = this;
  131. var appContainer;
  132. return _regenerator["default"].wrap(function _callee$(_context) {
  133. while (1) {
  134. switch (_context.prev = _context.next) {
  135. case 0:
  136. this.preferences = this.externalServices.createPreferences();
  137. this.appConfig = appConfig;
  138. _context.next = 4;
  139. return this._readPreferences();
  140. case 4:
  141. _context.next = 6;
  142. return this._parseHashParameters();
  143. case 6:
  144. _context.next = 8;
  145. return this._initializeL10n();
  146. case 8:
  147. if (this.isViewerEmbedded && _app_options.AppOptions.get('externalLinkTarget') === _pdf.LinkTarget.NONE) {
  148. _app_options.AppOptions.set('externalLinkTarget', _pdf.LinkTarget.TOP);
  149. }
  150. _context.next = 11;
  151. return this._initializeViewerComponents();
  152. case 11:
  153. this.bindEvents();
  154. this.bindWindowEvents();
  155. appContainer = appConfig.appContainer || document.documentElement;
  156. this.l10n.translate(appContainer).then(function () {
  157. _this.eventBus.dispatch('localized', {
  158. source: _this
  159. });
  160. });
  161. this.initialized = true;
  162. case 16:
  163. case "end":
  164. return _context.stop();
  165. }
  166. }
  167. }, _callee, this);
  168. }));
  169. function initialize(_x) {
  170. return _initialize.apply(this, arguments);
  171. }
  172. return initialize;
  173. }(),
  174. _readPreferences: function () {
  175. var _readPreferences2 = _asyncToGenerator(
  176. /*#__PURE__*/
  177. _regenerator["default"].mark(function _callee2() {
  178. var prefs, name;
  179. return _regenerator["default"].wrap(function _callee2$(_context2) {
  180. while (1) {
  181. switch (_context2.prev = _context2.next) {
  182. case 0:
  183. if (!(_app_options.AppOptions.get('disablePreferences') === true)) {
  184. _context2.next = 2;
  185. break;
  186. }
  187. return _context2.abrupt("return");
  188. case 2:
  189. _context2.prev = 2;
  190. _context2.next = 5;
  191. return this.preferences.getAll();
  192. case 5:
  193. prefs = _context2.sent;
  194. for (name in prefs) {
  195. _app_options.AppOptions.set(name, prefs[name]);
  196. }
  197. _context2.next = 12;
  198. break;
  199. case 9:
  200. _context2.prev = 9;
  201. _context2.t0 = _context2["catch"](2);
  202. console.error("_readPreferences: \"".concat(_context2.t0.message, "\"."));
  203. case 12:
  204. case "end":
  205. return _context2.stop();
  206. }
  207. }
  208. }, _callee2, this, [[2, 9]]);
  209. }));
  210. function _readPreferences() {
  211. return _readPreferences2.apply(this, arguments);
  212. }
  213. return _readPreferences;
  214. }(),
  215. _parseHashParameters: function () {
  216. var _parseHashParameters2 = _asyncToGenerator(
  217. /*#__PURE__*/
  218. _regenerator["default"].mark(function _callee3() {
  219. var waitOn, hash, hashParams, viewer, enabled;
  220. return _regenerator["default"].wrap(function _callee3$(_context3) {
  221. while (1) {
  222. switch (_context3.prev = _context3.next) {
  223. case 0:
  224. if (_app_options.AppOptions.get('pdfBugEnabled')) {
  225. _context3.next = 2;
  226. break;
  227. }
  228. return _context3.abrupt("return", undefined);
  229. case 2:
  230. waitOn = [];
  231. hash = document.location.hash.substring(1);
  232. hashParams = (0, _ui_utils.parseQueryString)(hash);
  233. if ('disableworker' in hashParams && hashParams['disableworker'] === 'true') {
  234. waitOn.push(loadFakeWorker());
  235. }
  236. if ('disablerange' in hashParams) {
  237. _app_options.AppOptions.set('disableRange', hashParams['disablerange'] === 'true');
  238. }
  239. if ('disablestream' in hashParams) {
  240. _app_options.AppOptions.set('disableStream', hashParams['disablestream'] === 'true');
  241. }
  242. if ('disableautofetch' in hashParams) {
  243. _app_options.AppOptions.set('disableAutoFetch', hashParams['disableautofetch'] === 'true');
  244. }
  245. if ('disablefontface' in hashParams) {
  246. _app_options.AppOptions.set('disableFontFace', hashParams['disablefontface'] === 'true');
  247. }
  248. if ('disablehistory' in hashParams) {
  249. _app_options.AppOptions.set('disableHistory', hashParams['disablehistory'] === 'true');
  250. }
  251. if ('webgl' in hashParams) {
  252. _app_options.AppOptions.set('enableWebGL', hashParams['webgl'] === 'true');
  253. }
  254. if ('useonlycsszoom' in hashParams) {
  255. _app_options.AppOptions.set('useOnlyCssZoom', hashParams['useonlycsszoom'] === 'true');
  256. }
  257. if ('verbosity' in hashParams) {
  258. _app_options.AppOptions.set('verbosity', hashParams['verbosity'] | 0);
  259. }
  260. if (!('textlayer' in hashParams)) {
  261. _context3.next = 23;
  262. break;
  263. }
  264. _context3.t0 = hashParams['textlayer'];
  265. _context3.next = _context3.t0 === 'off' ? 18 : _context3.t0 === 'visible' ? 20 : _context3.t0 === 'shadow' ? 20 : _context3.t0 === 'hover' ? 20 : 23;
  266. break;
  267. case 18:
  268. _app_options.AppOptions.set('textLayerMode', _ui_utils.TextLayerMode.DISABLE);
  269. return _context3.abrupt("break", 23);
  270. case 20:
  271. viewer = this.appConfig.viewerContainer;
  272. viewer.classList.add('textLayer-' + hashParams['textlayer']);
  273. return _context3.abrupt("break", 23);
  274. case 23:
  275. if ('pdfbug' in hashParams) {
  276. _app_options.AppOptions.set('pdfBug', true);
  277. enabled = hashParams['pdfbug'].split(',');
  278. waitOn.push(loadAndEnablePDFBug(enabled));
  279. }
  280. if ('locale' in hashParams) {
  281. _app_options.AppOptions.set('locale', hashParams['locale']);
  282. }
  283. return _context3.abrupt("return", Promise.all(waitOn)["catch"](function (reason) {
  284. console.error("_parseHashParameters: \"".concat(reason.message, "\"."));
  285. }));
  286. case 26:
  287. case "end":
  288. return _context3.stop();
  289. }
  290. }
  291. }, _callee3, this);
  292. }));
  293. function _parseHashParameters() {
  294. return _parseHashParameters2.apply(this, arguments);
  295. }
  296. return _parseHashParameters;
  297. }(),
  298. _initializeL10n: function () {
  299. var _initializeL10n2 = _asyncToGenerator(
  300. /*#__PURE__*/
  301. _regenerator["default"].mark(function _callee4() {
  302. var dir;
  303. return _regenerator["default"].wrap(function _callee4$(_context4) {
  304. while (1) {
  305. switch (_context4.prev = _context4.next) {
  306. case 0:
  307. this.l10n = this.externalServices.createL10n({
  308. locale: _app_options.AppOptions.get('locale')
  309. });
  310. _context4.next = 3;
  311. return this.l10n.getDirection();
  312. case 3:
  313. dir = _context4.sent;
  314. document.getElementsByTagName('html')[0].dir = dir;
  315. case 5:
  316. case "end":
  317. return _context4.stop();
  318. }
  319. }
  320. }, _callee4, this);
  321. }));
  322. function _initializeL10n() {
  323. return _initializeL10n2.apply(this, arguments);
  324. }
  325. return _initializeL10n;
  326. }(),
  327. _initializeViewerComponents: function () {
  328. var _initializeViewerComponents2 = _asyncToGenerator(
  329. /*#__PURE__*/
  330. _regenerator["default"].mark(function _callee5() {
  331. var appConfig, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, container, viewer;
  332. return _regenerator["default"].wrap(function _callee5$(_context5) {
  333. while (1) {
  334. switch (_context5.prev = _context5.next) {
  335. case 0:
  336. appConfig = this.appConfig;
  337. this.overlayManager = new _overlay_manager.OverlayManager();
  338. eventBus = appConfig.eventBus || (0, _ui_utils.getGlobalEventBus)(_app_options.AppOptions.get('eventBusDispatchToDOM'));
  339. this.eventBus = eventBus;
  340. pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  341. pdfRenderingQueue.onIdle = this.cleanup.bind(this);
  342. this.pdfRenderingQueue = pdfRenderingQueue;
  343. pdfLinkService = new _pdf_link_service.PDFLinkService({
  344. eventBus: eventBus,
  345. externalLinkTarget: _app_options.AppOptions.get('externalLinkTarget'),
  346. externalLinkRel: _app_options.AppOptions.get('externalLinkRel')
  347. });
  348. this.pdfLinkService = pdfLinkService;
  349. downloadManager = this.externalServices.createDownloadManager({
  350. disableCreateObjectURL: _app_options.AppOptions.get('disableCreateObjectURL')
  351. });
  352. this.downloadManager = downloadManager;
  353. findController = new _pdf_find_controller.PDFFindController({
  354. linkService: pdfLinkService,
  355. eventBus: eventBus
  356. });
  357. this.findController = findController;
  358. container = appConfig.mainContainer;
  359. viewer = appConfig.viewerContainer;
  360. this.pdfViewer = new _pdf_viewer.PDFViewer({
  361. container: container,
  362. viewer: viewer,
  363. eventBus: eventBus,
  364. renderingQueue: pdfRenderingQueue,
  365. linkService: pdfLinkService,
  366. downloadManager: downloadManager,
  367. findController: findController,
  368. renderer: _app_options.AppOptions.get('renderer'),
  369. enableWebGL: _app_options.AppOptions.get('enableWebGL'),
  370. l10n: this.l10n,
  371. textLayerMode: _app_options.AppOptions.get('textLayerMode'),
  372. imageResourcesPath: _app_options.AppOptions.get('imageResourcesPath'),
  373. renderInteractiveForms: _app_options.AppOptions.get('renderInteractiveForms'),
  374. enablePrintAutoRotate: _app_options.AppOptions.get('enablePrintAutoRotate'),
  375. useOnlyCssZoom: _app_options.AppOptions.get('useOnlyCssZoom'),
  376. maxCanvasPixels: _app_options.AppOptions.get('maxCanvasPixels')
  377. });
  378. pdfRenderingQueue.setViewer(this.pdfViewer);
  379. pdfLinkService.setViewer(this.pdfViewer);
  380. this.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
  381. container: appConfig.sidebar.thumbnailView,
  382. renderingQueue: pdfRenderingQueue,
  383. linkService: pdfLinkService,
  384. l10n: this.l10n
  385. });
  386. pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
  387. this.pdfHistory = new _pdf_history.PDFHistory({
  388. linkService: pdfLinkService,
  389. eventBus: eventBus
  390. });
  391. pdfLinkService.setHistory(this.pdfHistory);
  392. if (!this.supportsIntegratedFind) {
  393. this.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, this.l10n);
  394. }
  395. this.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, this.l10n);
  396. this.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
  397. container: container,
  398. eventBus: eventBus,
  399. cursorToolOnLoad: _app_options.AppOptions.get('cursorToolOnLoad')
  400. });
  401. this.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, this.l10n);
  402. this.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
  403. if (this.supportsFullscreen) {
  404. this.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
  405. container: container,
  406. viewer: viewer,
  407. pdfViewer: this.pdfViewer,
  408. eventBus: eventBus,
  409. contextMenuItems: appConfig.fullscreen
  410. });
  411. }
  412. this.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, this.l10n);
  413. this.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
  414. container: appConfig.sidebar.outlineView,
  415. eventBus: eventBus,
  416. linkService: pdfLinkService
  417. });
  418. this.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
  419. container: appConfig.sidebar.attachmentsView,
  420. eventBus: eventBus,
  421. downloadManager: downloadManager
  422. });
  423. this.pdfSidebar = new _pdf_sidebar.PDFSidebar({
  424. elements: appConfig.sidebar,
  425. pdfViewer: this.pdfViewer,
  426. pdfThumbnailViewer: this.pdfThumbnailViewer,
  427. eventBus: eventBus,
  428. l10n: this.l10n
  429. });
  430. this.pdfSidebar.onToggled = this.forceRendering.bind(this);
  431. this.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, this.l10n);
  432. case 34:
  433. case "end":
  434. return _context5.stop();
  435. }
  436. }
  437. }, _callee5, this);
  438. }));
  439. function _initializeViewerComponents() {
  440. return _initializeViewerComponents2.apply(this, arguments);
  441. }
  442. return _initializeViewerComponents;
  443. }(),
  444. run: function run(config) {
  445. this.initialize(config).then(webViewerInitialized);
  446. },
  447. zoomIn: function zoomIn(ticks) {
  448. if (this.pdfViewer.isInPresentationMode) {
  449. return;
  450. }
  451. var newScale = this.pdfViewer.currentScale;
  452. do {
  453. newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
  454. newScale = Math.ceil(newScale * 10) / 10;
  455. newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
  456. } while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE);
  457. this.pdfViewer.currentScaleValue = newScale;
  458. },
  459. zoomOut: function zoomOut(ticks) {
  460. if (this.pdfViewer.isInPresentationMode) {
  461. return;
  462. }
  463. var newScale = this.pdfViewer.currentScale;
  464. do {
  465. newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
  466. newScale = Math.floor(newScale * 10) / 10;
  467. newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
  468. } while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE);
  469. this.pdfViewer.currentScaleValue = newScale;
  470. },
  471. zoomReset: function zoomReset() {
  472. if (this.pdfViewer.isInPresentationMode) {
  473. return;
  474. }
  475. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  476. },
  477. get pagesCount() {
  478. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  479. },
  480. set page(val) {
  481. this.pdfViewer.currentPageNumber = val;
  482. },
  483. get page() {
  484. return this.pdfViewer.currentPageNumber;
  485. },
  486. get printing() {
  487. return !!this.printService;
  488. },
  489. get supportsPrinting() {
  490. return PDFPrintServiceFactory.instance.supportsPrinting;
  491. },
  492. get supportsFullscreen() {
  493. var support;
  494. var doc = document.documentElement;
  495. support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen);
  496. if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) {
  497. support = false;
  498. }
  499. return (0, _pdf.shadow)(this, 'supportsFullscreen', support);
  500. },
  501. get supportsIntegratedFind() {
  502. return this.externalServices.supportsIntegratedFind;
  503. },
  504. get supportsDocumentFonts() {
  505. return this.externalServices.supportsDocumentFonts;
  506. },
  507. get supportsDocumentColors() {
  508. return this.externalServices.supportsDocumentColors;
  509. },
  510. get loadingBar() {
  511. var bar = new _ui_utils.ProgressBar('#loadingBar');
  512. return (0, _pdf.shadow)(this, 'loadingBar', bar);
  513. },
  514. get supportedMouseWheelZoomModifierKeys() {
  515. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  516. },
  517. initPassiveLoading: function initPassiveLoading() {
  518. throw new Error('Not implemented: initPassiveLoading');
  519. },
  520. setTitleUsingUrl: function setTitleUsingUrl() {
  521. var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  522. this.url = url;
  523. this.baseUrl = url.split('#')[0];
  524. var title = (0, _ui_utils.getPDFFileNameFromURL)(url, '');
  525. if (!title) {
  526. try {
  527. title = decodeURIComponent((0, _pdf.getFilenameFromUrl)(url)) || url;
  528. } catch (ex) {
  529. title = url;
  530. }
  531. }
  532. this.setTitle(title);
  533. },
  534. setTitle: function setTitle(title) {
  535. if (this.isViewerEmbedded) {
  536. return;
  537. }
  538. document.title = title;
  539. },
  540. close: function () {
  541. var _close = _asyncToGenerator(
  542. /*#__PURE__*/
  543. _regenerator["default"].mark(function _callee6() {
  544. var errorWrapper, promise;
  545. return _regenerator["default"].wrap(function _callee6$(_context6) {
  546. while (1) {
  547. switch (_context6.prev = _context6.next) {
  548. case 0:
  549. errorWrapper = this.appConfig.errorWrapper.container;
  550. errorWrapper.setAttribute('hidden', 'true');
  551. if (this.pdfLoadingTask) {
  552. _context6.next = 4;
  553. break;
  554. }
  555. return _context6.abrupt("return", undefined);
  556. case 4:
  557. promise = this.pdfLoadingTask.destroy();
  558. this.pdfLoadingTask = null;
  559. if (this.pdfDocument) {
  560. this.pdfDocument = null;
  561. this.pdfThumbnailViewer.setDocument(null);
  562. this.pdfViewer.setDocument(null);
  563. this.pdfLinkService.setDocument(null);
  564. this.pdfDocumentProperties.setDocument(null);
  565. }
  566. this.store = null;
  567. this.isInitialViewSet = false;
  568. this.downloadComplete = false;
  569. this.url = '';
  570. this.baseUrl = '';
  571. this.contentDispositionFilename = null;
  572. this.pdfSidebar.reset();
  573. this.pdfOutlineViewer.reset();
  574. this.pdfAttachmentViewer.reset();
  575. if (this.findBar) {
  576. this.findBar.reset();
  577. }
  578. this.toolbar.reset();
  579. this.secondaryToolbar.reset();
  580. if (typeof PDFBug !== 'undefined') {
  581. PDFBug.cleanup();
  582. }
  583. return _context6.abrupt("return", promise);
  584. case 21:
  585. case "end":
  586. return _context6.stop();
  587. }
  588. }
  589. }, _callee6, this);
  590. }));
  591. function close() {
  592. return _close.apply(this, arguments);
  593. }
  594. return close;
  595. }(),
  596. open: function () {
  597. var _open = _asyncToGenerator(
  598. /*#__PURE__*/
  599. _regenerator["default"].mark(function _callee7(file, args) {
  600. var _this2 = this;
  601. var workerParameters, key, parameters, apiParameters, _key, value, _key2, _value, loadingTask;
  602. return _regenerator["default"].wrap(function _callee7$(_context7) {
  603. while (1) {
  604. switch (_context7.prev = _context7.next) {
  605. case 0:
  606. if (!this.pdfLoadingTask) {
  607. _context7.next = 3;
  608. break;
  609. }
  610. _context7.next = 3;
  611. return this.close();
  612. case 3:
  613. workerParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.WORKER);
  614. for (key in workerParameters) {
  615. _pdf.GlobalWorkerOptions[key] = workerParameters[key];
  616. }
  617. parameters = Object.create(null);
  618. if (typeof file === 'string') {
  619. this.setTitleUsingUrl(file);
  620. parameters.url = file;
  621. } else if (file && 'byteLength' in file) {
  622. parameters.data = file;
  623. } else if (file.url && file.originalUrl) {
  624. this.setTitleUsingUrl(file.originalUrl);
  625. parameters.url = file.url;
  626. }
  627. apiParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.API);
  628. for (_key in apiParameters) {
  629. value = apiParameters[_key];
  630. if (_key === 'docBaseUrl' && !value) {}
  631. parameters[_key] = value;
  632. }
  633. if (args) {
  634. for (_key2 in args) {
  635. _value = args[_key2];
  636. if (_key2 === 'length') {
  637. this.pdfDocumentProperties.setFileSize(_value);
  638. }
  639. parameters[_key2] = _value;
  640. }
  641. }
  642. loadingTask = (0, _pdf.getDocument)(parameters);
  643. this.pdfLoadingTask = loadingTask;
  644. loadingTask.onPassword = function (updateCallback, reason) {
  645. _this2.pdfLinkService.externalLinkEnabled = false;
  646. _this2.passwordPrompt.setUpdateCallback(updateCallback, reason);
  647. _this2.passwordPrompt.open();
  648. };
  649. loadingTask.onProgress = function (_ref) {
  650. var loaded = _ref.loaded,
  651. total = _ref.total;
  652. _this2.progress(loaded / total);
  653. };
  654. loadingTask.onUnsupportedFeature = this.fallback.bind(this);
  655. return _context7.abrupt("return", loadingTask.promise.then(function (pdfDocument) {
  656. _this2.load(pdfDocument);
  657. }, function (exception) {
  658. if (loadingTask !== _this2.pdfLoadingTask) {
  659. return undefined;
  660. }
  661. var message = exception && exception.message;
  662. var loadingErrorMessage;
  663. if (exception instanceof _pdf.InvalidPDFException) {
  664. loadingErrorMessage = _this2.l10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.');
  665. } else if (exception instanceof _pdf.MissingPDFException) {
  666. loadingErrorMessage = _this2.l10n.get('missing_file_error', null, 'Missing PDF file.');
  667. } else if (exception instanceof _pdf.UnexpectedResponseException) {
  668. loadingErrorMessage = _this2.l10n.get('unexpected_response_error', null, 'Unexpected server response.');
  669. } else {
  670. loadingErrorMessage = _this2.l10n.get('loading_error', null, 'An error occurred while loading the PDF.');
  671. }
  672. return loadingErrorMessage.then(function (msg) {
  673. _this2.error(msg, {
  674. message: message
  675. });
  676. throw new Error(msg);
  677. });
  678. }));
  679. case 16:
  680. case "end":
  681. return _context7.stop();
  682. }
  683. }
  684. }, _callee7, this);
  685. }));
  686. function open(_x2, _x3) {
  687. return _open.apply(this, arguments);
  688. }
  689. return open;
  690. }(),
  691. download: function download() {
  692. var _this3 = this;
  693. function downloadByUrl() {
  694. downloadManager.downloadUrl(url, filename);
  695. }
  696. var url = this.baseUrl;
  697. var filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url);
  698. var downloadManager = this.downloadManager;
  699. downloadManager.onerror = function (err) {
  700. _this3.error("PDF failed to download: ".concat(err));
  701. };
  702. if (!this.pdfDocument || !this.downloadComplete) {
  703. downloadByUrl();
  704. return;
  705. }
  706. this.pdfDocument.getData().then(function (data) {
  707. var blob = new Blob([data], {
  708. type: 'application/pdf'
  709. });
  710. downloadManager.download(blob, url, filename);
  711. })["catch"](downloadByUrl);
  712. },
  713. fallback: function fallback(featureId) {},
  714. error: function error(message, moreInfo) {
  715. var moreInfoText = [this.l10n.get('error_version_info', {
  716. version: _pdf.version || '?',
  717. build: _pdf.build || '?'
  718. }, 'PDF.js v{{version}} (build: {{build}})')];
  719. if (moreInfo) {
  720. moreInfoText.push(this.l10n.get('error_message', {
  721. message: moreInfo.message
  722. }, 'Message: {{message}}'));
  723. if (moreInfo.stack) {
  724. moreInfoText.push(this.l10n.get('error_stack', {
  725. stack: moreInfo.stack
  726. }, 'Stack: {{stack}}'));
  727. } else {
  728. if (moreInfo.filename) {
  729. moreInfoText.push(this.l10n.get('error_file', {
  730. file: moreInfo.filename
  731. }, 'File: {{file}}'));
  732. }
  733. if (moreInfo.lineNumber) {
  734. moreInfoText.push(this.l10n.get('error_line', {
  735. line: moreInfo.lineNumber
  736. }, 'Line: {{line}}'));
  737. }
  738. }
  739. }
  740. var errorWrapperConfig = this.appConfig.errorWrapper;
  741. var errorWrapper = errorWrapperConfig.container;
  742. errorWrapper.removeAttribute('hidden');
  743. var errorMessage = errorWrapperConfig.errorMessage;
  744. errorMessage.textContent = message;
  745. var closeButton = errorWrapperConfig.closeButton;
  746. closeButton.onclick = function () {
  747. errorWrapper.setAttribute('hidden', 'true');
  748. };
  749. var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
  750. var moreInfoButton = errorWrapperConfig.moreInfoButton;
  751. var lessInfoButton = errorWrapperConfig.lessInfoButton;
  752. moreInfoButton.onclick = function () {
  753. errorMoreInfo.removeAttribute('hidden');
  754. moreInfoButton.setAttribute('hidden', 'true');
  755. lessInfoButton.removeAttribute('hidden');
  756. errorMoreInfo.style.height = errorMoreInfo.scrollHeight + 'px';
  757. };
  758. lessInfoButton.onclick = function () {
  759. errorMoreInfo.setAttribute('hidden', 'true');
  760. moreInfoButton.removeAttribute('hidden');
  761. lessInfoButton.setAttribute('hidden', 'true');
  762. };
  763. moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  764. lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  765. closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  766. moreInfoButton.removeAttribute('hidden');
  767. lessInfoButton.setAttribute('hidden', 'true');
  768. Promise.all(moreInfoText).then(function (parts) {
  769. errorMoreInfo.value = parts.join('\n');
  770. });
  771. },
  772. progress: function progress(level) {
  773. var _this4 = this;
  774. if (this.downloadComplete) {
  775. return;
  776. }
  777. var percent = Math.round(level * 100);
  778. if (percent > this.loadingBar.percent || isNaN(percent)) {
  779. this.loadingBar.percent = percent;
  780. var disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams['disableAutoFetch'] : _app_options.AppOptions.get('disableAutoFetch');
  781. if (disableAutoFetch && percent) {
  782. if (this.disableAutoFetchLoadingBarTimeout) {
  783. clearTimeout(this.disableAutoFetchLoadingBarTimeout);
  784. this.disableAutoFetchLoadingBarTimeout = null;
  785. }
  786. this.loadingBar.show();
  787. this.disableAutoFetchLoadingBarTimeout = setTimeout(function () {
  788. _this4.loadingBar.hide();
  789. _this4.disableAutoFetchLoadingBarTimeout = null;
  790. }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
  791. }
  792. }
  793. },
  794. load: function load(pdfDocument) {
  795. var _this5 = this;
  796. this.pdfDocument = pdfDocument;
  797. pdfDocument.getDownloadInfo().then(function () {
  798. _this5.downloadComplete = true;
  799. _this5.loadingBar.hide();
  800. firstPagePromise.then(function () {
  801. _this5.eventBus.dispatch('documentloaded', {
  802. source: _this5
  803. });
  804. });
  805. });
  806. var pageLayoutPromise = pdfDocument.getPageLayout()["catch"](function () {});
  807. var pageModePromise = pdfDocument.getPageMode()["catch"](function () {});
  808. var openActionDestPromise = pdfDocument.getOpenActionDestination()["catch"](function () {});
  809. this.toolbar.setPagesCount(pdfDocument.numPages, false);
  810. this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
  811. var store = this.store = new _view_history.ViewHistory(pdfDocument.fingerprint);
  812. var baseDocumentUrl;
  813. baseDocumentUrl = null;
  814. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  815. this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
  816. var pdfViewer = this.pdfViewer;
  817. pdfViewer.setDocument(pdfDocument);
  818. var firstPagePromise = pdfViewer.firstPagePromise;
  819. var pagesPromise = pdfViewer.pagesPromise;
  820. var onePageRendered = pdfViewer.onePageRendered;
  821. var pdfThumbnailViewer = this.pdfThumbnailViewer;
  822. pdfThumbnailViewer.setDocument(pdfDocument);
  823. firstPagePromise.then(function (pdfPage) {
  824. _this5.loadingBar.setWidth(_this5.appConfig.viewerContainer);
  825. var storePromise = store.getMultiple({
  826. page: null,
  827. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  828. scrollLeft: '0',
  829. scrollTop: '0',
  830. rotation: null,
  831. sidebarView: _pdf_sidebar.SidebarView.UNKNOWN,
  832. scrollMode: _ui_utils.ScrollMode.UNKNOWN,
  833. spreadMode: _ui_utils.SpreadMode.UNKNOWN
  834. })["catch"](function () {});
  835. Promise.all([_ui_utils.animationStarted, storePromise, pageLayoutPromise, pageModePromise, openActionDestPromise]).then(
  836. /*#__PURE__*/
  837. function () {
  838. var _ref3 = _asyncToGenerator(
  839. /*#__PURE__*/
  840. _regenerator["default"].mark(function _callee8(_ref2) {
  841. var _ref4, timeStamp, _ref4$, values, pageLayout, pageMode, openActionDest, viewOnLoad, initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode;
  842. return _regenerator["default"].wrap(function _callee8$(_context8) {
  843. while (1) {
  844. switch (_context8.prev = _context8.next) {
  845. case 0:
  846. _ref4 = _slicedToArray(_ref2, 5), timeStamp = _ref4[0], _ref4$ = _ref4[1], values = _ref4$ === void 0 ? {} : _ref4$, pageLayout = _ref4[2], pageMode = _ref4[3], openActionDest = _ref4[4];
  847. viewOnLoad = _app_options.AppOptions.get('viewOnLoad');
  848. _this5._initializePdfHistory({
  849. fingerprint: pdfDocument.fingerprint,
  850. viewOnLoad: viewOnLoad,
  851. initialDest: openActionDest
  852. });
  853. initialBookmark = _this5.initialBookmark;
  854. zoom = _app_options.AppOptions.get('defaultZoomValue');
  855. hash = zoom ? "zoom=".concat(zoom) : null;
  856. rotation = null;
  857. sidebarView = _app_options.AppOptions.get('sidebarViewOnLoad');
  858. scrollMode = _app_options.AppOptions.get('scrollModeOnLoad');
  859. spreadMode = _app_options.AppOptions.get('spreadModeOnLoad');
  860. if (values.page && viewOnLoad !== ViewOnLoad.INITIAL) {
  861. hash = "page=".concat(values.page, "&zoom=").concat(zoom || values.zoom, ",") + "".concat(values.scrollLeft, ",").concat(values.scrollTop);
  862. rotation = parseInt(values.rotation, 10);
  863. if (sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
  864. sidebarView = values.sidebarView | 0;
  865. }
  866. if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
  867. scrollMode = values.scrollMode | 0;
  868. }
  869. if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  870. spreadMode = values.spreadMode | 0;
  871. }
  872. }
  873. if (pageMode && sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
  874. sidebarView = apiPageModeToSidebarView(pageMode);
  875. }
  876. if (pageLayout && spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  877. spreadMode = apiPageLayoutToSpreadMode(pageLayout);
  878. }
  879. _this5.setInitialView(hash, {
  880. rotation: rotation,
  881. sidebarView: sidebarView,
  882. scrollMode: scrollMode,
  883. spreadMode: spreadMode
  884. });
  885. _this5.eventBus.dispatch('documentinit', {
  886. source: _this5
  887. });
  888. if (!_this5.isViewerEmbedded) {
  889. pdfViewer.focus();
  890. }
  891. _context8.next = 18;
  892. return Promise.race([pagesPromise, new Promise(function (resolve) {
  893. setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
  894. })]);
  895. case 18:
  896. if (!(!initialBookmark && !hash)) {
  897. _context8.next = 20;
  898. break;
  899. }
  900. return _context8.abrupt("return");
  901. case 20:
  902. if (!pdfViewer.hasEqualPageSizes) {
  903. _context8.next = 22;
  904. break;
  905. }
  906. return _context8.abrupt("return");
  907. case 22:
  908. _this5.initialBookmark = initialBookmark;
  909. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  910. _this5.setInitialView(hash);
  911. case 25:
  912. case "end":
  913. return _context8.stop();
  914. }
  915. }
  916. }, _callee8);
  917. }));
  918. return function (_x4) {
  919. return _ref3.apply(this, arguments);
  920. };
  921. }())["catch"](function () {
  922. _this5.setInitialView();
  923. }).then(function () {
  924. pdfViewer.update();
  925. });
  926. });
  927. pdfDocument.getPageLabels().then(function (labels) {
  928. if (!labels || _app_options.AppOptions.get('disablePageLabels')) {
  929. return;
  930. }
  931. var i = 0,
  932. numLabels = labels.length;
  933. if (numLabels !== _this5.pagesCount) {
  934. console.error('The number of Page Labels does not match ' + 'the number of pages in the document.');
  935. return;
  936. }
  937. while (i < numLabels && labels[i] === (i + 1).toString()) {
  938. i++;
  939. }
  940. if (i === numLabels) {
  941. return;
  942. }
  943. pdfViewer.setPageLabels(labels);
  944. pdfThumbnailViewer.setPageLabels(labels);
  945. _this5.toolbar.setPagesCount(pdfDocument.numPages, true);
  946. _this5.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  947. });
  948. pagesPromise.then(function () {
  949. if (!_this5.supportsPrinting) {
  950. return;
  951. }
  952. pdfDocument.getJavaScript().then(function (javaScript) {
  953. if (!javaScript) {
  954. return;
  955. }
  956. javaScript.some(function (js) {
  957. if (!js) {
  958. return false;
  959. }
  960. console.warn('Warning: JavaScript is not supported');
  961. _this5.fallback(_pdf.UNSUPPORTED_FEATURES.javaScript);
  962. return true;
  963. });
  964. var regex = /\bprint\s*\(/;
  965. for (var i = 0, ii = javaScript.length; i < ii; i++) {
  966. var js = javaScript[i];
  967. if (js && regex.test(js)) {
  968. setTimeout(function () {
  969. window.print();
  970. });
  971. return;
  972. }
  973. }
  974. });
  975. });
  976. onePageRendered.then(function () {
  977. pdfDocument.getOutline().then(function (outline) {
  978. _this5.pdfOutlineViewer.render({
  979. outline: outline
  980. });
  981. });
  982. pdfDocument.getAttachments().then(function (attachments) {
  983. _this5.pdfAttachmentViewer.render({
  984. attachments: attachments
  985. });
  986. });
  987. });
  988. pdfDocument.getMetadata().then(function (_ref5) {
  989. var info = _ref5.info,
  990. metadata = _ref5.metadata,
  991. contentDispositionFilename = _ref5.contentDispositionFilename;
  992. _this5.documentInfo = info;
  993. _this5.metadata = metadata;
  994. _this5.contentDispositionFilename = contentDispositionFilename;
  995. console.log('PDF ' + pdfDocument.fingerprint + ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (_pdf.version || '-') + (_app_options.AppOptions.get('enableWebGL') ? ' [WebGL]' : '') + ')');
  996. var pdfTitle;
  997. if (metadata && metadata.has('dc:title')) {
  998. var title = metadata.get('dc:title');
  999. if (title !== 'Untitled') {
  1000. pdfTitle = title;
  1001. }
  1002. }
  1003. if (!pdfTitle && info && info['Title']) {
  1004. pdfTitle = info['Title'];
  1005. }
  1006. if (pdfTitle) {
  1007. _this5.setTitle("".concat(pdfTitle, " - ").concat(contentDispositionFilename || document.title));
  1008. } else if (contentDispositionFilename) {
  1009. _this5.setTitle(contentDispositionFilename);
  1010. }
  1011. if (info.IsAcroFormPresent) {
  1012. console.warn('Warning: AcroForm/XFA is not supported');
  1013. _this5.fallback(_pdf.UNSUPPORTED_FEATURES.forms);
  1014. }
  1015. });
  1016. },
  1017. _initializePdfHistory: function _initializePdfHistory(_ref6) {
  1018. var fingerprint = _ref6.fingerprint,
  1019. viewOnLoad = _ref6.viewOnLoad,
  1020. _ref6$initialDest = _ref6.initialDest,
  1021. initialDest = _ref6$initialDest === void 0 ? null : _ref6$initialDest;
  1022. if (_app_options.AppOptions.get('disableHistory') || this.isViewerEmbedded) {
  1023. return;
  1024. }
  1025. this.pdfHistory.initialize({
  1026. fingerprint: fingerprint,
  1027. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  1028. updateUrl: _app_options.AppOptions.get('historyUpdateUrl')
  1029. });
  1030. if (this.pdfHistory.initialBookmark) {
  1031. this.initialBookmark = this.pdfHistory.initialBookmark;
  1032. this.initialRotation = this.pdfHistory.initialRotation;
  1033. }
  1034. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  1035. this.initialBookmark = JSON.stringify(initialDest);
  1036. this.pdfHistory.push({
  1037. explicitDest: initialDest,
  1038. pageNumber: null
  1039. });
  1040. }
  1041. },
  1042. setInitialView: function setInitialView(storedHash) {
  1043. var _this6 = this;
  1044. var _ref7 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  1045. rotation = _ref7.rotation,
  1046. sidebarView = _ref7.sidebarView,
  1047. scrollMode = _ref7.scrollMode,
  1048. spreadMode = _ref7.spreadMode;
  1049. var setRotation = function setRotation(angle) {
  1050. if ((0, _ui_utils.isValidRotation)(angle)) {
  1051. _this6.pdfViewer.pagesRotation = angle;
  1052. }
  1053. };
  1054. var setViewerModes = function setViewerModes(scroll, spread) {
  1055. if ((0, _ui_utils.isValidScrollMode)(scroll)) {
  1056. _this6.pdfViewer.scrollMode = scroll;
  1057. }
  1058. if ((0, _ui_utils.isValidSpreadMode)(spread)) {
  1059. _this6.pdfViewer.spreadMode = spread;
  1060. }
  1061. };
  1062. this.isInitialViewSet = true;
  1063. this.pdfSidebar.setInitialView(sidebarView);
  1064. setViewerModes(scrollMode, spreadMode);
  1065. if (this.initialBookmark) {
  1066. setRotation(this.initialRotation);
  1067. delete this.initialRotation;
  1068. this.pdfLinkService.setHash(this.initialBookmark);
  1069. this.initialBookmark = null;
  1070. } else if (storedHash) {
  1071. setRotation(rotation);
  1072. this.pdfLinkService.setHash(storedHash);
  1073. }
  1074. this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  1075. this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
  1076. if (!this.pdfViewer.currentScaleValue) {
  1077. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1078. }
  1079. },
  1080. cleanup: function cleanup() {
  1081. if (!this.pdfDocument) {
  1082. return;
  1083. }
  1084. this.pdfViewer.cleanup();
  1085. this.pdfThumbnailViewer.cleanup();
  1086. if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
  1087. this.pdfDocument.cleanup();
  1088. }
  1089. },
  1090. forceRendering: function forceRendering() {
  1091. this.pdfRenderingQueue.printing = this.printing;
  1092. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
  1093. this.pdfRenderingQueue.renderHighestPriority();
  1094. },
  1095. beforePrint: function beforePrint() {
  1096. var _this7 = this;
  1097. if (this.printService) {
  1098. return;
  1099. }
  1100. if (!this.supportsPrinting) {
  1101. this.l10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by ' + 'this browser.').then(function (printMessage) {
  1102. _this7.error(printMessage);
  1103. });
  1104. return;
  1105. }
  1106. if (!this.pdfViewer.pageViewsReady) {
  1107. this.l10n.get('printing_not_ready', null, 'Warning: The PDF is not fully loaded for printing.').then(function (notReadyMessage) {
  1108. window.alert(notReadyMessage);
  1109. });
  1110. return;
  1111. }
  1112. var pagesOverview = this.pdfViewer.getPagesOverview();
  1113. var printContainer = this.appConfig.printContainer;
  1114. var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, this.l10n);
  1115. this.printService = printService;
  1116. this.forceRendering();
  1117. printService.layout();
  1118. },
  1119. afterPrint: function afterPrint() {
  1120. if (this.printService) {
  1121. this.printService.destroy();
  1122. this.printService = null;
  1123. }
  1124. this.forceRendering();
  1125. },
  1126. rotatePages: function rotatePages(delta) {
  1127. if (!this.pdfDocument) {
  1128. return;
  1129. }
  1130. var newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360;
  1131. this.pdfViewer.pagesRotation = newRotation;
  1132. },
  1133. requestPresentationMode: function requestPresentationMode() {
  1134. if (!this.pdfPresentationMode) {
  1135. return;
  1136. }
  1137. this.pdfPresentationMode.request();
  1138. },
  1139. bindEvents: function bindEvents() {
  1140. var eventBus = this.eventBus,
  1141. _boundEvents = this._boundEvents;
  1142. _boundEvents.beforePrint = this.beforePrint.bind(this);
  1143. _boundEvents.afterPrint = this.afterPrint.bind(this);
  1144. eventBus.on('resize', webViewerResize);
  1145. eventBus.on('hashchange', webViewerHashchange);
  1146. eventBus.on('beforeprint', _boundEvents.beforePrint);
  1147. eventBus.on('afterprint', _boundEvents.afterPrint);
  1148. eventBus.on('pagerendered', webViewerPageRendered);
  1149. eventBus.on('textlayerrendered', webViewerTextLayerRendered);
  1150. eventBus.on('updateviewarea', webViewerUpdateViewarea);
  1151. eventBus.on('pagechanging', webViewerPageChanging);
  1152. eventBus.on('scalechanging', webViewerScaleChanging);
  1153. eventBus.on('rotationchanging', webViewerRotationChanging);
  1154. eventBus.on('sidebarviewchanged', webViewerSidebarViewChanged);
  1155. eventBus.on('pagemode', webViewerPageMode);
  1156. eventBus.on('namedaction', webViewerNamedAction);
  1157. eventBus.on('presentationmodechanged', webViewerPresentationModeChanged);
  1158. eventBus.on('presentationmode', webViewerPresentationMode);
  1159. eventBus.on('openfile', webViewerOpenFile);
  1160. eventBus.on('print', webViewerPrint);
  1161. eventBus.on('download', webViewerDownload);
  1162. eventBus.on('firstpage', webViewerFirstPage);
  1163. eventBus.on('lastpage', webViewerLastPage);
  1164. eventBus.on('nextpage', webViewerNextPage);
  1165. eventBus.on('previouspage', webViewerPreviousPage);
  1166. eventBus.on('zoomin', webViewerZoomIn);
  1167. eventBus.on('zoomout', webViewerZoomOut);
  1168. eventBus.on('zoomreset', webViewerZoomReset);
  1169. eventBus.on('pagenumberchanged', webViewerPageNumberChanged);
  1170. eventBus.on('scalechanged', webViewerScaleChanged);
  1171. eventBus.on('rotatecw', webViewerRotateCw);
  1172. eventBus.on('rotateccw', webViewerRotateCcw);
  1173. eventBus.on('switchscrollmode', webViewerSwitchScrollMode);
  1174. eventBus.on('scrollmodechanged', webViewerScrollModeChanged);
  1175. eventBus.on('switchspreadmode', webViewerSwitchSpreadMode);
  1176. eventBus.on('spreadmodechanged', webViewerSpreadModeChanged);
  1177. eventBus.on('documentproperties', webViewerDocumentProperties);
  1178. eventBus.on('find', webViewerFind);
  1179. eventBus.on('findfromurlhash', webViewerFindFromUrlHash);
  1180. eventBus.on('updatefindmatchescount', webViewerUpdateFindMatchesCount);
  1181. eventBus.on('updatefindcontrolstate', webViewerUpdateFindControlState);
  1182. eventBus.on('fileinputchange', webViewerFileInputChange);
  1183. },
  1184. bindWindowEvents: function bindWindowEvents() {
  1185. var eventBus = this.eventBus,
  1186. _boundEvents = this._boundEvents;
  1187. _boundEvents.windowResize = function () {
  1188. eventBus.dispatch('resize', {
  1189. source: window
  1190. });
  1191. };
  1192. _boundEvents.windowHashChange = function () {
  1193. eventBus.dispatch('hashchange', {
  1194. source: window,
  1195. hash: document.location.hash.substring(1)
  1196. });
  1197. };
  1198. _boundEvents.windowBeforePrint = function () {
  1199. eventBus.dispatch('beforeprint', {
  1200. source: window
  1201. });
  1202. };
  1203. _boundEvents.windowAfterPrint = function () {
  1204. eventBus.dispatch('afterprint', {
  1205. source: window
  1206. });
  1207. };
  1208. window.addEventListener('visibilitychange', webViewerVisibilityChange);
  1209. window.addEventListener('wheel', webViewerWheel, {
  1210. passive: false
  1211. });
  1212. window.addEventListener('click', webViewerClick);
  1213. window.addEventListener('keydown', webViewerKeyDown);
  1214. window.addEventListener('resize', _boundEvents.windowResize);
  1215. window.addEventListener('hashchange', _boundEvents.windowHashChange);
  1216. window.addEventListener('beforeprint', _boundEvents.windowBeforePrint);
  1217. window.addEventListener('afterprint', _boundEvents.windowAfterPrint);
  1218. },
  1219. unbindEvents: function unbindEvents() {
  1220. var eventBus = this.eventBus,
  1221. _boundEvents = this._boundEvents;
  1222. eventBus.off('resize', webViewerResize);
  1223. eventBus.off('hashchange', webViewerHashchange);
  1224. eventBus.off('beforeprint', _boundEvents.beforePrint);
  1225. eventBus.off('afterprint', _boundEvents.afterPrint);
  1226. eventBus.off('pagerendered', webViewerPageRendered);
  1227. eventBus.off('textlayerrendered', webViewerTextLayerRendered);
  1228. eventBus.off('updateviewarea', webViewerUpdateViewarea);
  1229. eventBus.off('pagechanging', webViewerPageChanging);
  1230. eventBus.off('scalechanging', webViewerScaleChanging);
  1231. eventBus.off('rotationchanging', webViewerRotationChanging);
  1232. eventBus.off('sidebarviewchanged', webViewerSidebarViewChanged);
  1233. eventBus.off('pagemode', webViewerPageMode);
  1234. eventBus.off('namedaction', webViewerNamedAction);
  1235. eventBus.off('presentationmodechanged', webViewerPresentationModeChanged);
  1236. eventBus.off('presentationmode', webViewerPresentationMode);
  1237. eventBus.off('openfile', webViewerOpenFile);
  1238. eventBus.off('print', webViewerPrint);
  1239. eventBus.off('download', webViewerDownload);
  1240. eventBus.off('firstpage', webViewerFirstPage);
  1241. eventBus.off('lastpage', webViewerLastPage);
  1242. eventBus.off('nextpage', webViewerNextPage);
  1243. eventBus.off('previouspage', webViewerPreviousPage);
  1244. eventBus.off('zoomin', webViewerZoomIn);
  1245. eventBus.off('zoomout', webViewerZoomOut);
  1246. eventBus.off('zoomreset', webViewerZoomReset);
  1247. eventBus.off('pagenumberchanged', webViewerPageNumberChanged);
  1248. eventBus.off('scalechanged', webViewerScaleChanged);
  1249. eventBus.off('rotatecw', webViewerRotateCw);
  1250. eventBus.off('rotateccw', webViewerRotateCcw);
  1251. eventBus.off('switchscrollmode', webViewerSwitchScrollMode);
  1252. eventBus.off('scrollmodechanged', webViewerScrollModeChanged);
  1253. eventBus.off('switchspreadmode', webViewerSwitchSpreadMode);
  1254. eventBus.off('spreadmodechanged', webViewerSpreadModeChanged);
  1255. eventBus.off('documentproperties', webViewerDocumentProperties);
  1256. eventBus.off('find', webViewerFind);
  1257. eventBus.off('findfromurlhash', webViewerFindFromUrlHash);
  1258. eventBus.off('updatefindmatchescount', webViewerUpdateFindMatchesCount);
  1259. eventBus.off('updatefindcontrolstate', webViewerUpdateFindControlState);
  1260. eventBus.off('fileinputchange', webViewerFileInputChange);
  1261. _boundEvents.beforePrint = null;
  1262. _boundEvents.afterPrint = null;
  1263. },
  1264. unbindWindowEvents: function unbindWindowEvents() {
  1265. var _boundEvents = this._boundEvents;
  1266. window.removeEventListener('visibilitychange', webViewerVisibilityChange);
  1267. window.removeEventListener('wheel', webViewerWheel);
  1268. window.removeEventListener('click', webViewerClick);
  1269. window.removeEventListener('keydown', webViewerKeyDown);
  1270. window.removeEventListener('resize', _boundEvents.windowResize);
  1271. window.removeEventListener('hashchange', _boundEvents.windowHashChange);
  1272. window.removeEventListener('beforeprint', _boundEvents.windowBeforePrint);
  1273. window.removeEventListener('afterprint', _boundEvents.windowAfterPrint);
  1274. _boundEvents.windowResize = null;
  1275. _boundEvents.windowHashChange = null;
  1276. _boundEvents.windowBeforePrint = null;
  1277. _boundEvents.windowAfterPrint = null;
  1278. }
  1279. };
  1280. exports.PDFViewerApplication = PDFViewerApplication;
  1281. var validateFileURL;
  1282. {
  1283. var HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io'];
  1284. validateFileURL = function validateFileURL(file) {
  1285. if (file === undefined) {
  1286. return;
  1287. }
  1288. try {
  1289. var viewerOrigin = new URL(window.location.href).origin || 'null';
  1290. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  1291. return;
  1292. }
  1293. var _ref8 = new URL(file, window.location.href),
  1294. origin = _ref8.origin,
  1295. protocol = _ref8.protocol;
  1296. if (origin !== viewerOrigin && protocol !== 'blob:') {
  1297. throw new Error('file origin does not match viewer\'s');
  1298. }
  1299. } catch (ex) {
  1300. var message = ex && ex.message;
  1301. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (loadingErrorMessage) {
  1302. PDFViewerApplication.error(loadingErrorMessage, {
  1303. message: message
  1304. });
  1305. });
  1306. throw ex;
  1307. }
  1308. };
  1309. }
  1310. function loadFakeWorker() {
  1311. if (!_pdf.GlobalWorkerOptions.workerSrc) {
  1312. _pdf.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get('workerSrc');
  1313. }
  1314. return (0, _pdf.loadScript)(_pdf.PDFWorker.getWorkerSrc());
  1315. }
  1316. function loadAndEnablePDFBug(enabledTabs) {
  1317. var appConfig = PDFViewerApplication.appConfig;
  1318. return (0, _pdf.loadScript)(appConfig.debuggerScriptPath).then(function () {
  1319. PDFBug.enable(enabledTabs);
  1320. PDFBug.init({
  1321. OPS: _pdf.OPS,
  1322. createObjectURL: _pdf.createObjectURL
  1323. }, appConfig.mainContainer);
  1324. });
  1325. }
  1326. function webViewerInitialized() {
  1327. var appConfig = PDFViewerApplication.appConfig;
  1328. var file;
  1329. var queryString = document.location.search.substring(1);
  1330. var params = (0, _ui_utils.parseQueryString)(queryString);
  1331. file = 'file' in params ? params.file : _app_options.AppOptions.get('defaultUrl');
  1332. validateFileURL(file);
  1333. var fileInput = document.createElement('input');
  1334. fileInput.id = appConfig.openFileInputName;
  1335. fileInput.className = 'fileInput';
  1336. fileInput.setAttribute('type', 'file');
  1337. fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
  1338. document.body.appendChild(fileInput);
  1339. if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
  1340. appConfig.toolbar.openFile.setAttribute('hidden', 'true');
  1341. appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');
  1342. } else {
  1343. fileInput.value = null;
  1344. }
  1345. fileInput.addEventListener('change', function (evt) {
  1346. var files = evt.target.files;
  1347. if (!files || files.length === 0) {
  1348. return;
  1349. }
  1350. PDFViewerApplication.eventBus.dispatch('fileinputchange', {
  1351. source: this,
  1352. fileInput: evt.target
  1353. });
  1354. });
  1355. appConfig.mainContainer.addEventListener('dragover', function (evt) {
  1356. evt.preventDefault();
  1357. evt.dataTransfer.dropEffect = 'move';
  1358. });
  1359. appConfig.mainContainer.addEventListener('drop', function (evt) {
  1360. evt.preventDefault();
  1361. var files = evt.dataTransfer.files;
  1362. if (!files || files.length === 0) {
  1363. return;
  1364. }
  1365. PDFViewerApplication.eventBus.dispatch('fileinputchange', {
  1366. source: this,
  1367. fileInput: evt.dataTransfer
  1368. });
  1369. });
  1370. if (!PDFViewerApplication.supportsPrinting) {
  1371. appConfig.toolbar.print.classList.add('hidden');
  1372. appConfig.secondaryToolbar.printButton.classList.add('hidden');
  1373. }
  1374. if (!PDFViewerApplication.supportsFullscreen) {
  1375. appConfig.toolbar.presentationModeButton.classList.add('hidden');
  1376. appConfig.secondaryToolbar.presentationModeButton.classList.add('hidden');
  1377. }
  1378. if (PDFViewerApplication.supportsIntegratedFind) {
  1379. appConfig.toolbar.viewFind.classList.add('hidden');
  1380. }
  1381. appConfig.mainContainer.addEventListener('transitionend', function (evt) {
  1382. if (evt.target === this) {
  1383. PDFViewerApplication.eventBus.dispatch('resize', {
  1384. source: this
  1385. });
  1386. }
  1387. }, true);
  1388. try {
  1389. webViewerOpenFileViaURL(file);
  1390. } catch (reason) {
  1391. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (msg) {
  1392. PDFViewerApplication.error(msg, reason);
  1393. });
  1394. }
  1395. }
  1396. var webViewerOpenFileViaURL;
  1397. {
  1398. webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
  1399. if (file && file.lastIndexOf('file:', 0) === 0) {
  1400. PDFViewerApplication.setTitleUsingUrl(file);
  1401. var xhr = new XMLHttpRequest();
  1402. xhr.onload = function () {
  1403. PDFViewerApplication.open(new Uint8Array(xhr.response));
  1404. };
  1405. xhr.open('GET', file);
  1406. xhr.responseType = 'arraybuffer';
  1407. xhr.send();
  1408. return;
  1409. }
  1410. if (file) {
  1411. PDFViewerApplication.open(file);
  1412. }
  1413. };
  1414. }
  1415. function webViewerPageRendered(evt) {
  1416. var pageNumber = evt.pageNumber;
  1417. var pageIndex = pageNumber - 1;
  1418. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
  1419. if (pageNumber === PDFViewerApplication.page) {
  1420. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
  1421. }
  1422. if (!pageView) {
  1423. return;
  1424. }
  1425. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  1426. var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
  1427. thumbnailView.setImage(pageView);
  1428. }
  1429. if (typeof Stats !== 'undefined' && Stats.enabled && pageView.stats) {
  1430. Stats.add(pageNumber, pageView.stats);
  1431. }
  1432. if (pageView.error) {
  1433. PDFViewerApplication.l10n.get('rendering_error', null, 'An error occurred while rendering the page.').then(function (msg) {
  1434. PDFViewerApplication.error(msg, pageView.error);
  1435. });
  1436. }
  1437. }
  1438. function webViewerTextLayerRendered(evt) {}
  1439. function webViewerPageMode(evt) {
  1440. var mode = evt.mode,
  1441. view;
  1442. switch (mode) {
  1443. case 'thumbs':
  1444. view = _pdf_sidebar.SidebarView.THUMBS;
  1445. break;
  1446. case 'bookmarks':
  1447. case 'outline':
  1448. view = _pdf_sidebar.SidebarView.OUTLINE;
  1449. break;
  1450. case 'attachments':
  1451. view = _pdf_sidebar.SidebarView.ATTACHMENTS;
  1452. break;
  1453. case 'none':
  1454. view = _pdf_sidebar.SidebarView.NONE;
  1455. break;
  1456. default:
  1457. console.error('Invalid "pagemode" hash parameter: ' + mode);
  1458. return;
  1459. }
  1460. PDFViewerApplication.pdfSidebar.switchView(view, true);
  1461. }
  1462. function webViewerNamedAction(evt) {
  1463. var action = evt.action;
  1464. switch (action) {
  1465. case 'GoToPage':
  1466. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  1467. break;
  1468. case 'Find':
  1469. if (!PDFViewerApplication.supportsIntegratedFind) {
  1470. PDFViewerApplication.findBar.toggle();
  1471. }
  1472. break;
  1473. }
  1474. }
  1475. function webViewerPresentationModeChanged(evt) {
  1476. var active = evt.active,
  1477. switchInProgress = evt.switchInProgress;
  1478. PDFViewerApplication.pdfViewer.presentationModeState = switchInProgress ? _ui_utils.PresentationModeState.CHANGING : active ? _ui_utils.PresentationModeState.FULLSCREEN : _ui_utils.PresentationModeState.NORMAL;
  1479. }
  1480. function webViewerSidebarViewChanged(evt) {
  1481. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
  1482. var store = PDFViewerApplication.store;
  1483. if (store && PDFViewerApplication.isInitialViewSet) {
  1484. store.set('sidebarView', evt.view)["catch"](function () {});
  1485. }
  1486. }
  1487. function webViewerUpdateViewarea(evt) {
  1488. var location = evt.location,
  1489. store = PDFViewerApplication.store;
  1490. if (store && PDFViewerApplication.isInitialViewSet) {
  1491. store.setMultiple({
  1492. 'page': location.pageNumber,
  1493. 'zoom': location.scale,
  1494. 'scrollLeft': location.left,
  1495. 'scrollTop': location.top,
  1496. 'rotation': location.rotation
  1497. })["catch"](function () {});
  1498. }
  1499. var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  1500. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  1501. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  1502. var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
  1503. var loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
  1504. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
  1505. }
  1506. function webViewerScrollModeChanged(evt) {
  1507. var store = PDFViewerApplication.store;
  1508. if (store && PDFViewerApplication.isInitialViewSet) {
  1509. store.set('scrollMode', evt.mode)["catch"](function () {});
  1510. }
  1511. }
  1512. function webViewerSpreadModeChanged(evt) {
  1513. var store = PDFViewerApplication.store;
  1514. if (store && PDFViewerApplication.isInitialViewSet) {
  1515. store.set('spreadMode', evt.mode)["catch"](function () {});
  1516. }
  1517. }
  1518. function webViewerResize() {
  1519. var pdfDocument = PDFViewerApplication.pdfDocument,
  1520. pdfViewer = PDFViewerApplication.pdfViewer;
  1521. if (!pdfDocument) {
  1522. return;
  1523. }
  1524. var currentScaleValue = pdfViewer.currentScaleValue;
  1525. if (currentScaleValue === 'auto' || currentScaleValue === 'page-fit' || currentScaleValue === 'page-width') {
  1526. pdfViewer.currentScaleValue = currentScaleValue;
  1527. }
  1528. pdfViewer.update();
  1529. }
  1530. function webViewerHashchange(evt) {
  1531. var hash = evt.hash;
  1532. if (!hash) {
  1533. return;
  1534. }
  1535. if (!PDFViewerApplication.isInitialViewSet) {
  1536. PDFViewerApplication.initialBookmark = hash;
  1537. } else if (!PDFViewerApplication.pdfHistory.popStateInProgress) {
  1538. PDFViewerApplication.pdfLinkService.setHash(hash);
  1539. }
  1540. }
  1541. var webViewerFileInputChange;
  1542. {
  1543. webViewerFileInputChange = function webViewerFileInputChange(evt) {
  1544. if (PDFViewerApplication.pdfViewer && PDFViewerApplication.pdfViewer.isInPresentationMode) {
  1545. return;
  1546. }
  1547. var file = evt.fileInput.files[0];
  1548. if (URL.createObjectURL && !_app_options.AppOptions.get('disableCreateObjectURL')) {
  1549. var url = URL.createObjectURL(file);
  1550. if (file.name) {
  1551. url = {
  1552. url: url,
  1553. originalUrl: file.name
  1554. };
  1555. }
  1556. PDFViewerApplication.open(url);
  1557. } else {
  1558. PDFViewerApplication.setTitleUsingUrl(file.name);
  1559. var fileReader = new FileReader();
  1560. fileReader.onload = function webViewerChangeFileReaderOnload(evt) {
  1561. var buffer = evt.target.result;
  1562. PDFViewerApplication.open(new Uint8Array(buffer));
  1563. };
  1564. fileReader.readAsArrayBuffer(file);
  1565. }
  1566. var appConfig = PDFViewerApplication.appConfig;
  1567. appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true');
  1568. appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden', 'true');
  1569. appConfig.toolbar.download.setAttribute('hidden', 'true');
  1570. appConfig.secondaryToolbar.downloadButton.setAttribute('hidden', 'true');
  1571. };
  1572. }
  1573. function webViewerPresentationMode() {
  1574. PDFViewerApplication.requestPresentationMode();
  1575. }
  1576. function webViewerOpenFile() {
  1577. var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
  1578. document.getElementById(openFileInputName).click();
  1579. }
  1580. function webViewerPrint() {
  1581. window.print();
  1582. }
  1583. function webViewerDownload() {
  1584. PDFViewerApplication.download();
  1585. }
  1586. function webViewerFirstPage() {
  1587. if (PDFViewerApplication.pdfDocument) {
  1588. PDFViewerApplication.page = 1;
  1589. }
  1590. }
  1591. function webViewerLastPage() {
  1592. if (PDFViewerApplication.pdfDocument) {
  1593. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  1594. }
  1595. }
  1596. function webViewerNextPage() {
  1597. PDFViewerApplication.page++;
  1598. }
  1599. function webViewerPreviousPage() {
  1600. PDFViewerApplication.page--;
  1601. }
  1602. function webViewerZoomIn() {
  1603. PDFViewerApplication.zoomIn();
  1604. }
  1605. function webViewerZoomOut() {
  1606. PDFViewerApplication.zoomOut();
  1607. }
  1608. function webViewerZoomReset() {
  1609. PDFViewerApplication.zoomReset();
  1610. }
  1611. function webViewerPageNumberChanged(evt) {
  1612. var pdfViewer = PDFViewerApplication.pdfViewer;
  1613. if (evt.value !== '') {
  1614. pdfViewer.currentPageLabel = evt.value;
  1615. }
  1616. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  1617. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  1618. }
  1619. }
  1620. function webViewerScaleChanged(evt) {
  1621. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  1622. }
  1623. function webViewerRotateCw() {
  1624. PDFViewerApplication.rotatePages(90);
  1625. }
  1626. function webViewerRotateCcw() {
  1627. PDFViewerApplication.rotatePages(-90);
  1628. }
  1629. function webViewerSwitchScrollMode(evt) {
  1630. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  1631. }
  1632. function webViewerSwitchSpreadMode(evt) {
  1633. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  1634. }
  1635. function webViewerDocumentProperties() {
  1636. PDFViewerApplication.pdfDocumentProperties.open();
  1637. }
  1638. function webViewerFind(evt) {
  1639. PDFViewerApplication.findController.executeCommand('find' + evt.type, {
  1640. query: evt.query,
  1641. phraseSearch: evt.phraseSearch,
  1642. caseSensitive: evt.caseSensitive,
  1643. entireWord: evt.entireWord,
  1644. highlightAll: evt.highlightAll,
  1645. findPrevious: evt.findPrevious
  1646. });
  1647. }
  1648. function webViewerFindFromUrlHash(evt) {
  1649. PDFViewerApplication.findController.executeCommand('find', {
  1650. query: evt.query,
  1651. phraseSearch: evt.phraseSearch,
  1652. caseSensitive: false,
  1653. entireWord: false,
  1654. highlightAll: true,
  1655. findPrevious: false
  1656. });
  1657. }
  1658. function webViewerUpdateFindMatchesCount(_ref9) {
  1659. var matchesCount = _ref9.matchesCount;
  1660. if (PDFViewerApplication.supportsIntegratedFind) {
  1661. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  1662. } else {
  1663. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  1664. }
  1665. }
  1666. function webViewerUpdateFindControlState(_ref10) {
  1667. var state = _ref10.state,
  1668. previous = _ref10.previous,
  1669. matchesCount = _ref10.matchesCount;
  1670. if (PDFViewerApplication.supportsIntegratedFind) {
  1671. PDFViewerApplication.externalServices.updateFindControlState({
  1672. result: state,
  1673. findPrevious: previous,
  1674. matchesCount: matchesCount
  1675. });
  1676. } else {
  1677. PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
  1678. }
  1679. }
  1680. function webViewerScaleChanging(evt) {
  1681. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  1682. PDFViewerApplication.pdfViewer.update();
  1683. }
  1684. function webViewerRotationChanging(evt) {
  1685. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  1686. PDFViewerApplication.forceRendering();
  1687. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  1688. }
  1689. function webViewerPageChanging(evt) {
  1690. var page = evt.pageNumber;
  1691. PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);
  1692. PDFViewerApplication.secondaryToolbar.setPageNumber(page);
  1693. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  1694. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
  1695. }
  1696. if (typeof Stats !== 'undefined' && Stats.enabled) {
  1697. var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
  1698. if (pageView && pageView.stats) {
  1699. Stats.add(page, pageView.stats);
  1700. }
  1701. }
  1702. }
  1703. function webViewerVisibilityChange(evt) {
  1704. if (document.visibilityState === 'visible') {
  1705. setZoomDisabledTimeout();
  1706. }
  1707. }
  1708. var zoomDisabledTimeout = null;
  1709. function setZoomDisabledTimeout() {
  1710. if (zoomDisabledTimeout) {
  1711. clearTimeout(zoomDisabledTimeout);
  1712. }
  1713. zoomDisabledTimeout = setTimeout(function () {
  1714. zoomDisabledTimeout = null;
  1715. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  1716. }
  1717. function webViewerWheel(evt) {
  1718. var pdfViewer = PDFViewerApplication.pdfViewer,
  1719. supportedMouseWheelZoomModifierKeys = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
  1720. if (pdfViewer.isInPresentationMode) {
  1721. return;
  1722. }
  1723. if (evt.ctrlKey && supportedMouseWheelZoomModifierKeys.ctrlKey || evt.metaKey && supportedMouseWheelZoomModifierKeys.metaKey) {
  1724. evt.preventDefault();
  1725. if (zoomDisabledTimeout || document.visibilityState === 'hidden') {
  1726. return;
  1727. }
  1728. var previousScale = pdfViewer.currentScale;
  1729. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  1730. var MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;
  1731. var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
  1732. if (ticks < 0) {
  1733. PDFViewerApplication.zoomOut(-ticks);
  1734. } else {
  1735. PDFViewerApplication.zoomIn(ticks);
  1736. }
  1737. var currentScale = pdfViewer.currentScale;
  1738. if (previousScale !== currentScale) {
  1739. var scaleCorrectionFactor = currentScale / previousScale - 1;
  1740. var rect = pdfViewer.container.getBoundingClientRect();
  1741. var dx = evt.clientX - rect.left;
  1742. var dy = evt.clientY - rect.top;
  1743. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  1744. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
  1745. }
  1746. } else {
  1747. setZoomDisabledTimeout();
  1748. }
  1749. }
  1750. function webViewerClick(evt) {
  1751. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  1752. return;
  1753. }
  1754. var appConfig = PDFViewerApplication.appConfig;
  1755. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
  1756. PDFViewerApplication.secondaryToolbar.close();
  1757. }
  1758. }
  1759. function webViewerKeyDown(evt) {
  1760. if (PDFViewerApplication.overlayManager.active) {
  1761. return;
  1762. }
  1763. var handled = false,
  1764. ensureViewerFocused = false;
  1765. var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  1766. var pdfViewer = PDFViewerApplication.pdfViewer;
  1767. var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
  1768. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  1769. switch (evt.keyCode) {
  1770. case 70:
  1771. if (!PDFViewerApplication.supportsIntegratedFind) {
  1772. PDFViewerApplication.findBar.open();
  1773. handled = true;
  1774. }
  1775. break;
  1776. case 71:
  1777. if (!PDFViewerApplication.supportsIntegratedFind) {
  1778. var findState = PDFViewerApplication.findController.state;
  1779. if (findState) {
  1780. PDFViewerApplication.findController.executeCommand('findagain', {
  1781. query: findState.query,
  1782. phraseSearch: findState.phraseSearch,
  1783. caseSensitive: findState.caseSensitive,
  1784. entireWord: findState.entireWord,
  1785. highlightAll: findState.highlightAll,
  1786. findPrevious: cmd === 5 || cmd === 12
  1787. });
  1788. }
  1789. handled = true;
  1790. }
  1791. break;
  1792. case 61:
  1793. case 107:
  1794. case 187:
  1795. case 171:
  1796. if (!isViewerInPresentationMode) {
  1797. PDFViewerApplication.zoomIn();
  1798. }
  1799. handled = true;
  1800. break;
  1801. case 173:
  1802. case 109:
  1803. case 189:
  1804. if (!isViewerInPresentationMode) {
  1805. PDFViewerApplication.zoomOut();
  1806. }
  1807. handled = true;
  1808. break;
  1809. case 48:
  1810. case 96:
  1811. if (!isViewerInPresentationMode) {
  1812. setTimeout(function () {
  1813. PDFViewerApplication.zoomReset();
  1814. });
  1815. handled = false;
  1816. }
  1817. break;
  1818. case 38:
  1819. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  1820. PDFViewerApplication.page = 1;
  1821. handled = true;
  1822. ensureViewerFocused = true;
  1823. }
  1824. break;
  1825. case 40:
  1826. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  1827. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  1828. handled = true;
  1829. ensureViewerFocused = true;
  1830. }
  1831. break;
  1832. }
  1833. }
  1834. if (cmd === 1 || cmd === 8) {
  1835. switch (evt.keyCode) {
  1836. case 83:
  1837. PDFViewerApplication.download();
  1838. handled = true;
  1839. break;
  1840. }
  1841. }
  1842. if (cmd === 3 || cmd === 10) {
  1843. switch (evt.keyCode) {
  1844. case 80:
  1845. PDFViewerApplication.requestPresentationMode();
  1846. handled = true;
  1847. break;
  1848. case 71:
  1849. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  1850. handled = true;
  1851. break;
  1852. }
  1853. }
  1854. if (handled) {
  1855. if (ensureViewerFocused && !isViewerInPresentationMode) {
  1856. pdfViewer.focus();
  1857. }
  1858. evt.preventDefault();
  1859. return;
  1860. }
  1861. var curElement = document.activeElement || document.querySelector(':focus');
  1862. var curElementTagName = curElement && curElement.tagName.toUpperCase();
  1863. if (curElementTagName === 'INPUT' || curElementTagName === 'TEXTAREA' || curElementTagName === 'SELECT') {
  1864. if (evt.keyCode !== 27) {
  1865. return;
  1866. }
  1867. }
  1868. if (cmd === 0) {
  1869. var turnPage = 0,
  1870. turnOnlyIfPageFit = false;
  1871. switch (evt.keyCode) {
  1872. case 38:
  1873. case 33:
  1874. if (pdfViewer.isVerticalScrollbarEnabled) {
  1875. turnOnlyIfPageFit = true;
  1876. }
  1877. turnPage = -1;
  1878. break;
  1879. case 8:
  1880. if (!isViewerInPresentationMode) {
  1881. turnOnlyIfPageFit = true;
  1882. }
  1883. turnPage = -1;
  1884. break;
  1885. case 37:
  1886. if (pdfViewer.isHorizontalScrollbarEnabled) {
  1887. turnOnlyIfPageFit = true;
  1888. }
  1889. case 75:
  1890. case 80:
  1891. turnPage = -1;
  1892. break;
  1893. case 27:
  1894. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  1895. PDFViewerApplication.secondaryToolbar.close();
  1896. handled = true;
  1897. }
  1898. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
  1899. PDFViewerApplication.findBar.close();
  1900. handled = true;
  1901. }
  1902. break;
  1903. case 40:
  1904. case 34:
  1905. if (pdfViewer.isVerticalScrollbarEnabled) {
  1906. turnOnlyIfPageFit = true;
  1907. }
  1908. turnPage = 1;
  1909. break;
  1910. case 13:
  1911. case 32:
  1912. if (!isViewerInPresentationMode) {
  1913. turnOnlyIfPageFit = true;
  1914. }
  1915. turnPage = 1;
  1916. break;
  1917. case 39:
  1918. if (pdfViewer.isHorizontalScrollbarEnabled) {
  1919. turnOnlyIfPageFit = true;
  1920. }
  1921. case 74:
  1922. case 78:
  1923. turnPage = 1;
  1924. break;
  1925. case 36:
  1926. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  1927. PDFViewerApplication.page = 1;
  1928. handled = true;
  1929. ensureViewerFocused = true;
  1930. }
  1931. break;
  1932. case 35:
  1933. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  1934. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  1935. handled = true;
  1936. ensureViewerFocused = true;
  1937. }
  1938. break;
  1939. case 83:
  1940. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT);
  1941. break;
  1942. case 72:
  1943. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND);
  1944. break;
  1945. case 82:
  1946. PDFViewerApplication.rotatePages(90);
  1947. break;
  1948. case 115:
  1949. PDFViewerApplication.pdfSidebar.toggle();
  1950. break;
  1951. }
  1952. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === 'page-fit')) {
  1953. if (turnPage > 0) {
  1954. if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  1955. PDFViewerApplication.page++;
  1956. }
  1957. } else {
  1958. if (PDFViewerApplication.page > 1) {
  1959. PDFViewerApplication.page--;
  1960. }
  1961. }
  1962. handled = true;
  1963. }
  1964. }
  1965. if (cmd === 4) {
  1966. switch (evt.keyCode) {
  1967. case 13:
  1968. case 32:
  1969. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
  1970. break;
  1971. }
  1972. if (PDFViewerApplication.page > 1) {
  1973. PDFViewerApplication.page--;
  1974. }
  1975. handled = true;
  1976. break;
  1977. case 82:
  1978. PDFViewerApplication.rotatePages(-90);
  1979. break;
  1980. }
  1981. }
  1982. if (!handled && !isViewerInPresentationMode) {
  1983. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== 'BUTTON') {
  1984. ensureViewerFocused = true;
  1985. }
  1986. }
  1987. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  1988. pdfViewer.focus();
  1989. }
  1990. if (handled) {
  1991. evt.preventDefault();
  1992. }
  1993. }
  1994. function apiPageLayoutToSpreadMode(layout) {
  1995. switch (layout) {
  1996. case 'SinglePage':
  1997. case 'OneColumn':
  1998. return _ui_utils.SpreadMode.NONE;
  1999. case 'TwoColumnLeft':
  2000. case 'TwoPageLeft':
  2001. return _ui_utils.SpreadMode.ODD;
  2002. case 'TwoColumnRight':
  2003. case 'TwoPageRight':
  2004. return _ui_utils.SpreadMode.EVEN;
  2005. }
  2006. return _ui_utils.SpreadMode.NONE;
  2007. }
  2008. function apiPageModeToSidebarView(mode) {
  2009. switch (mode) {
  2010. case 'UseNone':
  2011. return _pdf_sidebar.SidebarView.NONE;
  2012. case 'UseThumbs':
  2013. return _pdf_sidebar.SidebarView.THUMBS;
  2014. case 'UseOutlines':
  2015. return _pdf_sidebar.SidebarView.OUTLINE;
  2016. case 'UseAttachments':
  2017. return _pdf_sidebar.SidebarView.ATTACHMENTS;
  2018. case 'UseOC':
  2019. }
  2020. return _pdf_sidebar.SidebarView.NONE;
  2021. }
  2022. var PDFPrintServiceFactory = {
  2023. instance: {
  2024. supportsPrinting: false,
  2025. createPrintService: function createPrintService() {
  2026. throw new Error('Not implemented: createPrintService');
  2027. }
  2028. }
  2029. };
  2030. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;