base_viewer.js 38 KB

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