2
0

base_viewer.js 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2020 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.BaseViewer = void 0;
  27. var _pdf = require("../pdf");
  28. var _ui_utils = require("./ui_utils.js");
  29. var _pdf_rendering_queue = require("./pdf_rendering_queue.js");
  30. var _annotation_layer_builder = require("./annotation_layer_builder.js");
  31. var _pdf_page_view = require("./pdf_page_view.js");
  32. var _pdf_link_service = require("./pdf_link_service.js");
  33. var _text_layer_builder = require("./text_layer_builder.js");
  34. const DEFAULT_CACHE_SIZE = 10;
  35. function PDFPageViewBuffer(size) {
  36. const data = [];
  37. this.push = function (view) {
  38. const i = data.indexOf(view);
  39. if (i >= 0) {
  40. data.splice(i, 1);
  41. }
  42. data.push(view);
  43. if (data.length > size) {
  44. data.shift().destroy();
  45. }
  46. };
  47. this.resize = function (newSize, pagesToKeep) {
  48. size = newSize;
  49. if (pagesToKeep) {
  50. const pageIdsToKeep = new Set();
  51. for (let i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  52. pageIdsToKeep.add(pagesToKeep[i].id);
  53. }
  54. (0, _ui_utils.moveToEndOfArray)(data, function (page) {
  55. return pageIdsToKeep.has(page.id);
  56. });
  57. }
  58. while (data.length > size) {
  59. data.shift().destroy();
  60. }
  61. };
  62. this.has = function (view) {
  63. return data.includes(view);
  64. };
  65. }
  66. function isSameScale(oldScale, newScale) {
  67. if (newScale === oldScale) {
  68. return true;
  69. }
  70. if (Math.abs(newScale - oldScale) < 1e-15) {
  71. return true;
  72. }
  73. return false;
  74. }
  75. class BaseViewer {
  76. constructor(options) {
  77. if (this.constructor === BaseViewer) {
  78. throw new Error("Cannot initialize BaseViewer.");
  79. }
  80. const viewerVersion = '2.7.570';
  81. if (_pdf.version !== viewerVersion) {
  82. throw new Error(`The API version "${_pdf.version}" does not match the Viewer version "${viewerVersion}".`);
  83. }
  84. this._name = this.constructor.name;
  85. this.container = options.container;
  86. this.viewer = options.viewer || options.container.firstElementChild;
  87. if (!(this.container?.tagName.toUpperCase() === "DIV" && this.viewer?.tagName.toUpperCase() === "DIV")) {
  88. throw new Error("Invalid `container` and/or `viewer` option.");
  89. }
  90. if (getComputedStyle(this.container).position !== "absolute") {
  91. throw new Error("The `container` must be absolutely positioned.");
  92. }
  93. this.eventBus = options.eventBus;
  94. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  95. this.downloadManager = options.downloadManager || null;
  96. this.findController = options.findController || null;
  97. this.removePageBorders = options.removePageBorders || false;
  98. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  99. this.imageResourcesPath = options.imageResourcesPath || "";
  100. this.renderInteractiveForms = typeof options.renderInteractiveForms === "boolean" ? options.renderInteractiveForms : true;
  101. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  102. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  103. this.enableWebGL = options.enableWebGL || false;
  104. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  105. this.maxCanvasPixels = options.maxCanvasPixels;
  106. this.l10n = options.l10n || _ui_utils.NullL10n;
  107. this.enableScripting = options.enableScripting || false;
  108. this._mouseState = options.mouseState || null;
  109. this.defaultRenderingQueue = !options.renderingQueue;
  110. if (this.defaultRenderingQueue) {
  111. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  112. this.renderingQueue.setViewer(this);
  113. } else {
  114. this.renderingQueue = options.renderingQueue;
  115. }
  116. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  117. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  118. this._onBeforeDraw = this._onAfterDraw = null;
  119. this._resetView();
  120. if (this.removePageBorders) {
  121. this.viewer.classList.add("removePageBorders");
  122. }
  123. Promise.resolve().then(() => {
  124. this.eventBus.dispatch("baseviewerinit", {
  125. source: this
  126. });
  127. });
  128. }
  129. get pagesCount() {
  130. return this._pages.length;
  131. }
  132. getPageView(index) {
  133. return this._pages[index];
  134. }
  135. get pageViewsReady() {
  136. if (!this._pagesCapability.settled) {
  137. return false;
  138. }
  139. return this._pages.every(function (pageView) {
  140. return pageView && pageView.pdfPage;
  141. });
  142. }
  143. get currentPageNumber() {
  144. return this._currentPageNumber;
  145. }
  146. set currentPageNumber(val) {
  147. if (!Number.isInteger(val)) {
  148. throw new Error("Invalid page number.");
  149. }
  150. if (!this.pdfDocument) {
  151. return;
  152. }
  153. if (!this._setCurrentPageNumber(val, true)) {
  154. console.error(`${this._name}.currentPageNumber: "${val}" is not a valid page.`);
  155. }
  156. }
  157. _setCurrentPageNumber(val, resetCurrentPageView = false) {
  158. if (this._currentPageNumber === val) {
  159. if (resetCurrentPageView) {
  160. this._resetCurrentPageView();
  161. }
  162. return true;
  163. }
  164. if (!(0 < val && val <= this.pagesCount)) {
  165. return false;
  166. }
  167. const previous = this._currentPageNumber;
  168. this._currentPageNumber = val;
  169. this.eventBus.dispatch("pagechanging", {
  170. source: this,
  171. pageNumber: val,
  172. pageLabel: this._pageLabels && this._pageLabels[val - 1],
  173. previous
  174. });
  175. if (resetCurrentPageView) {
  176. this._resetCurrentPageView();
  177. }
  178. return true;
  179. }
  180. get currentPageLabel() {
  181. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  182. }
  183. set currentPageLabel(val) {
  184. if (!this.pdfDocument) {
  185. return;
  186. }
  187. let page = val | 0;
  188. if (this._pageLabels) {
  189. const i = this._pageLabels.indexOf(val);
  190. if (i >= 0) {
  191. page = i + 1;
  192. }
  193. }
  194. if (!this._setCurrentPageNumber(page, true)) {
  195. console.error(`${this._name}.currentPageLabel: "${val}" is not a valid page.`);
  196. }
  197. }
  198. get currentScale() {
  199. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  200. }
  201. set currentScale(val) {
  202. if (isNaN(val)) {
  203. throw new Error("Invalid numeric scale.");
  204. }
  205. if (!this.pdfDocument) {
  206. return;
  207. }
  208. this._setScale(val, false);
  209. }
  210. get currentScaleValue() {
  211. return this._currentScaleValue;
  212. }
  213. set currentScaleValue(val) {
  214. if (!this.pdfDocument) {
  215. return;
  216. }
  217. this._setScale(val, false);
  218. }
  219. get pagesRotation() {
  220. return this._pagesRotation;
  221. }
  222. set pagesRotation(rotation) {
  223. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  224. throw new Error("Invalid pages rotation angle.");
  225. }
  226. if (!this.pdfDocument) {
  227. return;
  228. }
  229. if (this._pagesRotation === rotation) {
  230. return;
  231. }
  232. this._pagesRotation = rotation;
  233. const pageNumber = this._currentPageNumber;
  234. for (let i = 0, ii = this._pages.length; i < ii; i++) {
  235. const pageView = this._pages[i];
  236. pageView.update(pageView.scale, rotation);
  237. }
  238. if (this._currentScaleValue) {
  239. this._setScale(this._currentScaleValue, true);
  240. }
  241. this.eventBus.dispatch("rotationchanging", {
  242. source: this,
  243. pagesRotation: rotation,
  244. pageNumber
  245. });
  246. if (this.defaultRenderingQueue) {
  247. this.update();
  248. }
  249. }
  250. get firstPagePromise() {
  251. return this.pdfDocument ? this._firstPageCapability.promise : null;
  252. }
  253. get onePageRendered() {
  254. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  255. }
  256. get pagesPromise() {
  257. return this.pdfDocument ? this._pagesCapability.promise : null;
  258. }
  259. get _viewerElement() {
  260. throw new Error("Not implemented: _viewerElement");
  261. }
  262. _onePageRenderedOrForceFetch() {
  263. if (!this.container.offsetParent || this._getVisiblePages().views.length === 0) {
  264. return Promise.resolve();
  265. }
  266. return this._onePageRenderedCapability.promise;
  267. }
  268. setDocument(pdfDocument) {
  269. if (this.pdfDocument) {
  270. this.eventBus.dispatch("pagesdestroy", {
  271. source: this
  272. });
  273. this._cancelRendering();
  274. this._resetView();
  275. if (this.findController) {
  276. this.findController.setDocument(null);
  277. }
  278. }
  279. this.pdfDocument = pdfDocument;
  280. if (!pdfDocument) {
  281. return;
  282. }
  283. const pagesCount = pdfDocument.numPages;
  284. const firstPagePromise = pdfDocument.getPage(1);
  285. const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  286. this._pagesCapability.promise.then(() => {
  287. this.eventBus.dispatch("pagesloaded", {
  288. source: this,
  289. pagesCount
  290. });
  291. });
  292. this._onBeforeDraw = evt => {
  293. const pageView = this._pages[evt.pageNumber - 1];
  294. if (!pageView) {
  295. return;
  296. }
  297. this._buffer.push(pageView);
  298. };
  299. this.eventBus._on("pagerender", this._onBeforeDraw);
  300. this._onAfterDraw = evt => {
  301. if (evt.cssTransform || this._onePageRenderedCapability.settled) {
  302. return;
  303. }
  304. this._onePageRenderedCapability.resolve();
  305. this.eventBus._off("pagerendered", this._onAfterDraw);
  306. this._onAfterDraw = null;
  307. };
  308. this.eventBus._on("pagerendered", this._onAfterDraw);
  309. firstPagePromise.then(firstPdfPage => {
  310. this._firstPageCapability.resolve(firstPdfPage);
  311. this._optionalContentConfigPromise = optionalContentConfigPromise;
  312. const scale = this.currentScale;
  313. const viewport = firstPdfPage.getViewport({
  314. scale: scale * _ui_utils.CSS_UNITS
  315. });
  316. const textLayerFactory = this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE ? this : null;
  317. for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  318. const pageView = new _pdf_page_view.PDFPageView({
  319. container: this._viewerElement,
  320. eventBus: this.eventBus,
  321. id: pageNum,
  322. scale,
  323. defaultViewport: viewport.clone(),
  324. optionalContentConfigPromise,
  325. renderingQueue: this.renderingQueue,
  326. textLayerFactory,
  327. textLayerMode: this.textLayerMode,
  328. annotationLayerFactory: this,
  329. imageResourcesPath: this.imageResourcesPath,
  330. renderInteractiveForms: this.renderInteractiveForms,
  331. renderer: this.renderer,
  332. enableWebGL: this.enableWebGL,
  333. useOnlyCssZoom: this.useOnlyCssZoom,
  334. maxCanvasPixels: this.maxCanvasPixels,
  335. l10n: this.l10n,
  336. enableScripting: this.enableScripting
  337. });
  338. this._pages.push(pageView);
  339. }
  340. const firstPageView = this._pages[0];
  341. if (firstPageView) {
  342. firstPageView.setPdfPage(firstPdfPage);
  343. this.linkService.cachePageRef(1, firstPdfPage.ref);
  344. }
  345. if (this._spreadMode !== _ui_utils.SpreadMode.NONE) {
  346. this._updateSpreadMode();
  347. }
  348. this._onePageRenderedOrForceFetch().then(() => {
  349. if (this.findController) {
  350. this.findController.setDocument(pdfDocument);
  351. }
  352. if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > 7500) {
  353. this._pagesCapability.resolve();
  354. return;
  355. }
  356. let getPagesLeft = pagesCount - 1;
  357. if (getPagesLeft <= 0) {
  358. this._pagesCapability.resolve();
  359. return;
  360. }
  361. for (let pageNum = 2; pageNum <= pagesCount; ++pageNum) {
  362. pdfDocument.getPage(pageNum).then(pdfPage => {
  363. const pageView = this._pages[pageNum - 1];
  364. if (!pageView.pdfPage) {
  365. pageView.setPdfPage(pdfPage);
  366. }
  367. this.linkService.cachePageRef(pageNum, pdfPage.ref);
  368. if (--getPagesLeft === 0) {
  369. this._pagesCapability.resolve();
  370. }
  371. }, reason => {
  372. console.error(`Unable to get page ${pageNum} to initialize viewer`, reason);
  373. if (--getPagesLeft === 0) {
  374. this._pagesCapability.resolve();
  375. }
  376. });
  377. }
  378. });
  379. this.eventBus.dispatch("pagesinit", {
  380. source: this
  381. });
  382. if (this.defaultRenderingQueue) {
  383. this.update();
  384. }
  385. }).catch(reason => {
  386. console.error("Unable to initialize viewer", reason);
  387. });
  388. }
  389. setPageLabels(labels) {
  390. if (!this.pdfDocument) {
  391. return;
  392. }
  393. if (!labels) {
  394. this._pageLabels = null;
  395. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  396. this._pageLabels = null;
  397. console.error(`${this._name}.setPageLabels: Invalid page labels.`);
  398. } else {
  399. this._pageLabels = labels;
  400. }
  401. for (let i = 0, ii = this._pages.length; i < ii; i++) {
  402. const pageView = this._pages[i];
  403. const label = this._pageLabels && this._pageLabels[i];
  404. pageView.setPageLabel(label);
  405. }
  406. }
  407. _resetView() {
  408. this._pages = [];
  409. this._currentPageNumber = 1;
  410. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  411. this._currentScaleValue = null;
  412. this._pageLabels = null;
  413. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  414. this._location = null;
  415. this._pagesRotation = 0;
  416. this._optionalContentConfigPromise = null;
  417. this._pagesRequests = new WeakMap();
  418. this._firstPageCapability = (0, _pdf.createPromiseCapability)();
  419. this._onePageRenderedCapability = (0, _pdf.createPromiseCapability)();
  420. this._pagesCapability = (0, _pdf.createPromiseCapability)();
  421. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  422. this._spreadMode = _ui_utils.SpreadMode.NONE;
  423. if (this._onBeforeDraw) {
  424. this.eventBus._off("pagerender", this._onBeforeDraw);
  425. this._onBeforeDraw = null;
  426. }
  427. if (this._onAfterDraw) {
  428. this.eventBus._off("pagerendered", this._onAfterDraw);
  429. this._onAfterDraw = null;
  430. }
  431. this._resetScriptingEvents();
  432. this.viewer.textContent = "";
  433. this._updateScrollMode();
  434. }
  435. _scrollUpdate() {
  436. if (this.pagesCount === 0) {
  437. return;
  438. }
  439. this.update();
  440. }
  441. _scrollIntoView({
  442. pageDiv,
  443. pageSpot = null,
  444. pageNumber = null
  445. }) {
  446. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  447. }
  448. _setScaleUpdatePages(newScale, newValue, noScroll = false, preset = false) {
  449. this._currentScaleValue = newValue.toString();
  450. if (isSameScale(this._currentScale, newScale)) {
  451. if (preset) {
  452. this.eventBus.dispatch("scalechanging", {
  453. source: this,
  454. scale: newScale,
  455. presetValue: newValue
  456. });
  457. }
  458. return;
  459. }
  460. for (let i = 0, ii = this._pages.length; i < ii; i++) {
  461. this._pages[i].update(newScale);
  462. }
  463. this._currentScale = newScale;
  464. if (!noScroll) {
  465. let page = this._currentPageNumber,
  466. dest;
  467. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  468. page = this._location.pageNumber;
  469. dest = [null, {
  470. name: "XYZ"
  471. }, this._location.left, this._location.top, null];
  472. }
  473. this.scrollPageIntoView({
  474. pageNumber: page,
  475. destArray: dest,
  476. allowNegativeOffset: true
  477. });
  478. }
  479. this.eventBus.dispatch("scalechanging", {
  480. source: this,
  481. scale: newScale,
  482. presetValue: preset ? newValue : undefined
  483. });
  484. if (this.defaultRenderingQueue) {
  485. this.update();
  486. }
  487. }
  488. get _pageWidthScaleFactor() {
  489. if (this.spreadMode !== _ui_utils.SpreadMode.NONE && this.scrollMode !== _ui_utils.ScrollMode.HORIZONTAL && !this.isInPresentationMode) {
  490. return 2;
  491. }
  492. return 1;
  493. }
  494. _setScale(value, noScroll = false) {
  495. let scale = parseFloat(value);
  496. if (scale > 0) {
  497. this._setScaleUpdatePages(scale, value, noScroll, false);
  498. } else {
  499. const currentPage = this._pages[this._currentPageNumber - 1];
  500. if (!currentPage) {
  501. return;
  502. }
  503. const noPadding = this.isInPresentationMode || this.removePageBorders;
  504. let hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  505. let vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  506. if (!noPadding && this._isScrollModeHorizontal) {
  507. [hPadding, vPadding] = [vPadding, hPadding];
  508. }
  509. const pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale / this._pageWidthScaleFactor;
  510. const pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  511. switch (value) {
  512. case "page-actual":
  513. scale = 1;
  514. break;
  515. case "page-width":
  516. scale = pageWidthScale;
  517. break;
  518. case "page-height":
  519. scale = pageHeightScale;
  520. break;
  521. case "page-fit":
  522. scale = Math.min(pageWidthScale, pageHeightScale);
  523. break;
  524. case "auto":
  525. const horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  526. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  527. break;
  528. default:
  529. console.error(`${this._name}._setScale: "${value}" is an unknown zoom value.`);
  530. return;
  531. }
  532. this._setScaleUpdatePages(scale, value, noScroll, true);
  533. }
  534. }
  535. _resetCurrentPageView() {
  536. if (this.isInPresentationMode) {
  537. this._setScale(this._currentScaleValue, true);
  538. }
  539. const pageView = this._pages[this._currentPageNumber - 1];
  540. this._scrollIntoView({
  541. pageDiv: pageView.div
  542. });
  543. }
  544. pageLabelToPageNumber(label) {
  545. if (!this._pageLabels) {
  546. return null;
  547. }
  548. const i = this._pageLabels.indexOf(label);
  549. if (i < 0) {
  550. return null;
  551. }
  552. return i + 1;
  553. }
  554. scrollPageIntoView({
  555. pageNumber,
  556. destArray = null,
  557. allowNegativeOffset = false,
  558. ignoreDestinationZoom = false
  559. }) {
  560. if (!this.pdfDocument) {
  561. return;
  562. }
  563. const pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  564. if (!pageView) {
  565. console.error(`${this._name}.scrollPageIntoView: ` + `"${pageNumber}" is not a valid pageNumber parameter.`);
  566. return;
  567. }
  568. if (this.isInPresentationMode || !destArray) {
  569. this._setCurrentPageNumber(pageNumber, true);
  570. return;
  571. }
  572. let x = 0,
  573. y = 0;
  574. let width = 0,
  575. height = 0,
  576. widthScale,
  577. heightScale;
  578. const changeOrientation = pageView.rotation % 180 !== 0;
  579. const pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  580. const pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  581. let scale = 0;
  582. switch (destArray[1].name) {
  583. case "XYZ":
  584. x = destArray[2];
  585. y = destArray[3];
  586. scale = destArray[4];
  587. x = x !== null ? x : 0;
  588. y = y !== null ? y : pageHeight;
  589. break;
  590. case "Fit":
  591. case "FitB":
  592. scale = "page-fit";
  593. break;
  594. case "FitH":
  595. case "FitBH":
  596. y = destArray[2];
  597. scale = "page-width";
  598. if (y === null && this._location) {
  599. x = this._location.left;
  600. y = this._location.top;
  601. } else if (typeof y !== "number") {
  602. y = pageHeight;
  603. }
  604. break;
  605. case "FitV":
  606. case "FitBV":
  607. x = destArray[2];
  608. width = pageWidth;
  609. height = pageHeight;
  610. scale = "page-height";
  611. break;
  612. case "FitR":
  613. x = destArray[2];
  614. y = destArray[3];
  615. width = destArray[4] - x;
  616. height = destArray[5] - y;
  617. const hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  618. const vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  619. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  620. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  621. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  622. break;
  623. default:
  624. console.error(`${this._name}.scrollPageIntoView: ` + `"${destArray[1].name}" is not a valid destination type.`);
  625. return;
  626. }
  627. if (!ignoreDestinationZoom) {
  628. if (scale && scale !== this._currentScale) {
  629. this.currentScaleValue = scale;
  630. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  631. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  632. }
  633. }
  634. if (scale === "page-fit" && !destArray[4]) {
  635. this._scrollIntoView({
  636. pageDiv: pageView.div,
  637. pageNumber
  638. });
  639. return;
  640. }
  641. const boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  642. let left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  643. let top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  644. if (!allowNegativeOffset) {
  645. left = Math.max(left, 0);
  646. top = Math.max(top, 0);
  647. }
  648. this._scrollIntoView({
  649. pageDiv: pageView.div,
  650. pageSpot: {
  651. left,
  652. top
  653. },
  654. pageNumber
  655. });
  656. }
  657. _updateLocation(firstPage) {
  658. const currentScale = this._currentScale;
  659. const currentScaleValue = this._currentScaleValue;
  660. const normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  661. const pageNumber = firstPage.id;
  662. let pdfOpenParams = "#page=" + pageNumber;
  663. pdfOpenParams += "&zoom=" + normalizedScaleValue;
  664. const currentPageView = this._pages[pageNumber - 1];
  665. const container = this.container;
  666. const topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  667. const intLeft = Math.round(topLeft[0]);
  668. const intTop = Math.round(topLeft[1]);
  669. pdfOpenParams += "," + intLeft + "," + intTop;
  670. this._location = {
  671. pageNumber,
  672. scale: normalizedScaleValue,
  673. top: intTop,
  674. left: intLeft,
  675. rotation: this._pagesRotation,
  676. pdfOpenParams
  677. };
  678. }
  679. _updateHelper(visiblePages) {
  680. throw new Error("Not implemented: _updateHelper");
  681. }
  682. update() {
  683. const visible = this._getVisiblePages();
  684. const visiblePages = visible.views,
  685. numVisiblePages = visiblePages.length;
  686. if (numVisiblePages === 0) {
  687. return;
  688. }
  689. const newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  690. this._buffer.resize(newCacheSize, visiblePages);
  691. this.renderingQueue.renderHighestPriority(visible);
  692. this._updateHelper(visiblePages);
  693. this._updateLocation(visible.first);
  694. this.eventBus.dispatch("updateviewarea", {
  695. source: this,
  696. location: this._location
  697. });
  698. }
  699. containsElement(element) {
  700. return this.container.contains(element);
  701. }
  702. focus() {
  703. this.container.focus();
  704. }
  705. get _isScrollModeHorizontal() {
  706. return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
  707. }
  708. get _isContainerRtl() {
  709. return getComputedStyle(this.container).direction === "rtl";
  710. }
  711. get isInPresentationMode() {
  712. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  713. }
  714. get isChangingPresentationMode() {
  715. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  716. }
  717. get isHorizontalScrollbarEnabled() {
  718. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  719. }
  720. get isVerticalScrollbarEnabled() {
  721. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  722. }
  723. _getCurrentVisiblePage() {
  724. if (!this.pagesCount) {
  725. return {
  726. views: []
  727. };
  728. }
  729. const pageView = this._pages[this._currentPageNumber - 1];
  730. const element = pageView.div;
  731. const view = {
  732. id: pageView.id,
  733. x: element.offsetLeft + element.clientLeft,
  734. y: element.offsetTop + element.clientTop,
  735. view: pageView
  736. };
  737. return {
  738. first: view,
  739. last: view,
  740. views: [view]
  741. };
  742. }
  743. _getVisiblePages() {
  744. return (0, _ui_utils.getVisibleElements)({
  745. scrollEl: this.container,
  746. views: this._pages,
  747. sortByVisibility: true,
  748. horizontal: this._isScrollModeHorizontal,
  749. rtl: this._isScrollModeHorizontal && this._isContainerRtl
  750. });
  751. }
  752. isPageVisible(pageNumber) {
  753. if (!this.pdfDocument) {
  754. return false;
  755. }
  756. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  757. console.error(`${this._name}.isPageVisible: "${pageNumber}" is not a valid page.`);
  758. return false;
  759. }
  760. return this._getVisiblePages().views.some(function (view) {
  761. return view.id === pageNumber;
  762. });
  763. }
  764. isPageCached(pageNumber) {
  765. if (!this.pdfDocument || !this._buffer) {
  766. return false;
  767. }
  768. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  769. console.error(`${this._name}.isPageCached: "${pageNumber}" is not a valid page.`);
  770. return false;
  771. }
  772. const pageView = this._pages[pageNumber - 1];
  773. if (!pageView) {
  774. return false;
  775. }
  776. return this._buffer.has(pageView);
  777. }
  778. cleanup() {
  779. for (let i = 0, ii = this._pages.length; i < ii; i++) {
  780. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  781. this._pages[i].reset();
  782. }
  783. }
  784. }
  785. _cancelRendering() {
  786. for (let i = 0, ii = this._pages.length; i < ii; i++) {
  787. if (this._pages[i]) {
  788. this._pages[i].cancelRendering();
  789. }
  790. }
  791. }
  792. _ensurePdfPageLoaded(pageView) {
  793. if (pageView.pdfPage) {
  794. return Promise.resolve(pageView.pdfPage);
  795. }
  796. if (this._pagesRequests.has(pageView)) {
  797. return this._pagesRequests.get(pageView);
  798. }
  799. const promise = this.pdfDocument.getPage(pageView.id).then(pdfPage => {
  800. if (!pageView.pdfPage) {
  801. pageView.setPdfPage(pdfPage);
  802. }
  803. this._pagesRequests.delete(pageView);
  804. return pdfPage;
  805. }).catch(reason => {
  806. console.error("Unable to get page for page view", reason);
  807. this._pagesRequests.delete(pageView);
  808. });
  809. this._pagesRequests.set(pageView, promise);
  810. return promise;
  811. }
  812. forceRendering(currentlyVisiblePages) {
  813. const visiblePages = currentlyVisiblePages || this._getVisiblePages();
  814. const scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
  815. const pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
  816. if (pageView) {
  817. this._ensurePdfPageLoaded(pageView).then(() => {
  818. this.renderingQueue.renderView(pageView);
  819. });
  820. return true;
  821. }
  822. return false;
  823. }
  824. createTextLayerBuilder(textLayerDiv, pageIndex, viewport, enhanceTextSelection = false, eventBus) {
  825. return new _text_layer_builder.TextLayerBuilder({
  826. textLayerDiv,
  827. eventBus,
  828. pageIndex,
  829. viewport,
  830. findController: this.isInPresentationMode ? null : this.findController,
  831. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  832. });
  833. }
  834. createAnnotationLayerBuilder(pageDiv, pdfPage, annotationStorage = null, imageResourcesPath = "", renderInteractiveForms = false, l10n = _ui_utils.NullL10n, enableScripting = false, hasJSActionsPromise = null, mouseState = null) {
  835. return new _annotation_layer_builder.AnnotationLayerBuilder({
  836. pageDiv,
  837. pdfPage,
  838. annotationStorage: annotationStorage || this.pdfDocument?.annotationStorage,
  839. imageResourcesPath,
  840. renderInteractiveForms,
  841. linkService: this.linkService,
  842. downloadManager: this.downloadManager,
  843. l10n,
  844. enableScripting,
  845. hasJSActionsPromise: hasJSActionsPromise || this.pdfDocument?.hasJSActions(),
  846. mouseState: mouseState || this._mouseState
  847. });
  848. }
  849. get hasEqualPageSizes() {
  850. const firstPageView = this._pages[0];
  851. for (let i = 1, ii = this._pages.length; i < ii; ++i) {
  852. const pageView = this._pages[i];
  853. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  854. return false;
  855. }
  856. }
  857. return true;
  858. }
  859. getPagesOverview() {
  860. const pagesOverview = this._pages.map(function (pageView) {
  861. const viewport = pageView.pdfPage.getViewport({
  862. scale: 1
  863. });
  864. return {
  865. width: viewport.width,
  866. height: viewport.height,
  867. rotation: viewport.rotation
  868. };
  869. });
  870. if (!this.enablePrintAutoRotate) {
  871. return pagesOverview;
  872. }
  873. return pagesOverview.map(function (size) {
  874. if ((0, _ui_utils.isPortraitOrientation)(size)) {
  875. return size;
  876. }
  877. return {
  878. width: size.height,
  879. height: size.width,
  880. rotation: (size.rotation + 90) % 360
  881. };
  882. });
  883. }
  884. get optionalContentConfigPromise() {
  885. if (!this.pdfDocument) {
  886. return Promise.resolve(null);
  887. }
  888. if (!this._optionalContentConfigPromise) {
  889. return this.pdfDocument.getOptionalContentConfig();
  890. }
  891. return this._optionalContentConfigPromise;
  892. }
  893. set optionalContentConfigPromise(promise) {
  894. if (!(promise instanceof Promise)) {
  895. throw new Error(`Invalid optionalContentConfigPromise: ${promise}`);
  896. }
  897. if (!this.pdfDocument) {
  898. return;
  899. }
  900. if (!this._optionalContentConfigPromise) {
  901. return;
  902. }
  903. this._optionalContentConfigPromise = promise;
  904. for (const pageView of this._pages) {
  905. pageView.update(pageView.scale, pageView.rotation, promise);
  906. }
  907. this.update();
  908. this.eventBus.dispatch("optionalcontentconfigchanged", {
  909. source: this,
  910. promise
  911. });
  912. }
  913. get scrollMode() {
  914. return this._scrollMode;
  915. }
  916. set scrollMode(mode) {
  917. if (this._scrollMode === mode) {
  918. return;
  919. }
  920. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  921. throw new Error(`Invalid scroll mode: ${mode}`);
  922. }
  923. this._scrollMode = mode;
  924. this.eventBus.dispatch("scrollmodechanged", {
  925. source: this,
  926. mode
  927. });
  928. this._updateScrollMode(this._currentPageNumber);
  929. }
  930. _updateScrollMode(pageNumber = null) {
  931. const scrollMode = this._scrollMode,
  932. viewer = this.viewer;
  933. viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  934. viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils.ScrollMode.WRAPPED);
  935. if (!this.pdfDocument || !pageNumber) {
  936. return;
  937. }
  938. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  939. this._setScale(this._currentScaleValue, true);
  940. }
  941. this._setCurrentPageNumber(pageNumber, true);
  942. this.update();
  943. }
  944. get spreadMode() {
  945. return this._spreadMode;
  946. }
  947. set spreadMode(mode) {
  948. if (this._spreadMode === mode) {
  949. return;
  950. }
  951. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  952. throw new Error(`Invalid spread mode: ${mode}`);
  953. }
  954. this._spreadMode = mode;
  955. this.eventBus.dispatch("spreadmodechanged", {
  956. source: this,
  957. mode
  958. });
  959. this._updateSpreadMode(this._currentPageNumber);
  960. }
  961. _updateSpreadMode(pageNumber = null) {
  962. if (!this.pdfDocument) {
  963. return;
  964. }
  965. const viewer = this.viewer,
  966. pages = this._pages;
  967. viewer.textContent = "";
  968. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  969. for (let i = 0, iMax = pages.length; i < iMax; ++i) {
  970. viewer.appendChild(pages[i].div);
  971. }
  972. } else {
  973. const parity = this._spreadMode - 1;
  974. let spread = null;
  975. for (let i = 0, iMax = pages.length; i < iMax; ++i) {
  976. if (spread === null) {
  977. spread = document.createElement("div");
  978. spread.className = "spread";
  979. viewer.appendChild(spread);
  980. } else if (i % 2 === parity) {
  981. spread = spread.cloneNode(false);
  982. viewer.appendChild(spread);
  983. }
  984. spread.appendChild(pages[i].div);
  985. }
  986. }
  987. if (!pageNumber) {
  988. return;
  989. }
  990. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  991. this._setScale(this._currentScaleValue, true);
  992. }
  993. this._setCurrentPageNumber(pageNumber, true);
  994. this.update();
  995. }
  996. _getPageAdvance(currentPageNumber, previous = false) {
  997. if (this.isInPresentationMode) {
  998. return 1;
  999. }
  1000. switch (this._scrollMode) {
  1001. case _ui_utils.ScrollMode.WRAPPED:
  1002. {
  1003. const {
  1004. views
  1005. } = this._getVisiblePages(),
  1006. pageLayout = new Map();
  1007. for (const {
  1008. id,
  1009. y,
  1010. percent,
  1011. widthPercent
  1012. } of views) {
  1013. if (percent === 0 || widthPercent < 100) {
  1014. continue;
  1015. }
  1016. let yArray = pageLayout.get(y);
  1017. if (!yArray) {
  1018. pageLayout.set(y, yArray || (yArray = []));
  1019. }
  1020. yArray.push(id);
  1021. }
  1022. for (const yArray of pageLayout.values()) {
  1023. const currentIndex = yArray.indexOf(currentPageNumber);
  1024. if (currentIndex === -1) {
  1025. continue;
  1026. }
  1027. const numPages = yArray.length;
  1028. if (numPages === 1) {
  1029. break;
  1030. }
  1031. if (previous) {
  1032. for (let i = currentIndex - 1, ii = 0; i >= ii; i--) {
  1033. const currentId = yArray[i],
  1034. expectedId = yArray[i + 1] - 1;
  1035. if (currentId < expectedId) {
  1036. return currentPageNumber - expectedId;
  1037. }
  1038. }
  1039. } else {
  1040. for (let i = currentIndex + 1, ii = numPages; i < ii; i++) {
  1041. const currentId = yArray[i],
  1042. expectedId = yArray[i - 1] + 1;
  1043. if (currentId > expectedId) {
  1044. return expectedId - currentPageNumber;
  1045. }
  1046. }
  1047. }
  1048. if (previous) {
  1049. const firstId = yArray[0];
  1050. if (firstId < currentPageNumber) {
  1051. return currentPageNumber - firstId + 1;
  1052. }
  1053. } else {
  1054. const lastId = yArray[numPages - 1];
  1055. if (lastId > currentPageNumber) {
  1056. return lastId - currentPageNumber + 1;
  1057. }
  1058. }
  1059. break;
  1060. }
  1061. break;
  1062. }
  1063. case _ui_utils.ScrollMode.HORIZONTAL:
  1064. {
  1065. break;
  1066. }
  1067. case _ui_utils.ScrollMode.VERTICAL:
  1068. {
  1069. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  1070. break;
  1071. }
  1072. const parity = this._spreadMode - 1;
  1073. if (previous && currentPageNumber % 2 !== parity) {
  1074. break;
  1075. } else if (!previous && currentPageNumber % 2 === parity) {
  1076. break;
  1077. }
  1078. const {
  1079. views
  1080. } = this._getVisiblePages(),
  1081. expectedId = previous ? currentPageNumber - 1 : currentPageNumber + 1;
  1082. for (const {
  1083. id,
  1084. percent,
  1085. widthPercent
  1086. } of views) {
  1087. if (id !== expectedId) {
  1088. continue;
  1089. }
  1090. if (percent > 0 && widthPercent === 100) {
  1091. return 2;
  1092. }
  1093. break;
  1094. }
  1095. break;
  1096. }
  1097. }
  1098. return 1;
  1099. }
  1100. nextPage() {
  1101. const currentPageNumber = this._currentPageNumber,
  1102. pagesCount = this.pagesCount;
  1103. if (currentPageNumber >= pagesCount) {
  1104. return false;
  1105. }
  1106. const advance = this._getPageAdvance(currentPageNumber, false) || 1;
  1107. this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount);
  1108. return true;
  1109. }
  1110. previousPage() {
  1111. const currentPageNumber = this._currentPageNumber;
  1112. if (currentPageNumber <= 1) {
  1113. return false;
  1114. }
  1115. const advance = this._getPageAdvance(currentPageNumber, true) || 1;
  1116. this.currentPageNumber = Math.max(currentPageNumber - advance, 1);
  1117. return true;
  1118. }
  1119. initializeScriptingEvents() {
  1120. if (!this.enableScripting || this._pageOpenPendingSet) {
  1121. return;
  1122. }
  1123. const eventBus = this.eventBus,
  1124. pageOpenPendingSet = this._pageOpenPendingSet = new Set(),
  1125. scriptingEvents = this._scriptingEvents || (this._scriptingEvents = Object.create(null));
  1126. const dispatchPageClose = pageNumber => {
  1127. if (pageOpenPendingSet.has(pageNumber)) {
  1128. return;
  1129. }
  1130. eventBus.dispatch("pageclose", {
  1131. source: this,
  1132. pageNumber
  1133. });
  1134. };
  1135. const dispatchPageOpen = pageNumber => {
  1136. const pageView = this._pages[pageNumber - 1];
  1137. if (pageView?.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
  1138. pageOpenPendingSet.delete(pageNumber);
  1139. eventBus.dispatch("pageopen", {
  1140. source: this,
  1141. pageNumber,
  1142. actionsPromise: pageView.pdfPage?.getJSActions()
  1143. });
  1144. } else {
  1145. pageOpenPendingSet.add(pageNumber);
  1146. }
  1147. };
  1148. scriptingEvents.onPageChanging = ({
  1149. pageNumber,
  1150. previous
  1151. }) => {
  1152. if (pageNumber === previous) {
  1153. return;
  1154. }
  1155. dispatchPageClose(previous);
  1156. dispatchPageOpen(pageNumber);
  1157. };
  1158. eventBus._on("pagechanging", scriptingEvents.onPageChanging);
  1159. scriptingEvents.onPageRendered = ({
  1160. pageNumber
  1161. }) => {
  1162. if (!pageOpenPendingSet.has(pageNumber)) {
  1163. return;
  1164. }
  1165. if (pageNumber !== this._currentPageNumber) {
  1166. return;
  1167. }
  1168. dispatchPageOpen(pageNumber);
  1169. };
  1170. eventBus._on("pagerendered", scriptingEvents.onPageRendered);
  1171. scriptingEvents.onPagesDestroy = () => {
  1172. dispatchPageClose(this._currentPageNumber);
  1173. };
  1174. eventBus._on("pagesdestroy", scriptingEvents.onPagesDestroy);
  1175. dispatchPageOpen(this._currentPageNumber);
  1176. }
  1177. _resetScriptingEvents() {
  1178. if (!this.enableScripting || !this._pageOpenPendingSet) {
  1179. return;
  1180. }
  1181. const eventBus = this.eventBus,
  1182. scriptingEvents = this._scriptingEvents;
  1183. eventBus._off("pagechanging", scriptingEvents.onPageChanging);
  1184. scriptingEvents.onPageChanging = null;
  1185. eventBus._off("pagerendered", scriptingEvents.onPageRendered);
  1186. scriptingEvents.onPageRendered = null;
  1187. eventBus._off("pagesdestroy", scriptingEvents.onPagesDestroy);
  1188. scriptingEvents.onPagesDestroy = null;
  1189. this._pageOpenPendingSet = null;
  1190. }
  1191. }
  1192. exports.BaseViewer = BaseViewer;