2 * @licstart The following is the entire license notice for the
3 * Javascript code in this page
5 * Copyright 2021 Mozilla Foundation
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @licend The above is the entire license notice for the
20 * Javascript code in this page
23 /******/ (() => { // webpackBootstrap
24 /******/ "use strict";
25 /******/ var __webpack_modules__
= ([
28 /***/ ((__unused_webpack_module
, exports
, __webpack_require__
) => {
32 Object
.defineProperty(exports
, "__esModule", ({
35 exports
.OptionKind
= exports
.AppOptions
= void 0;
37 var _viewer_compatibility
= __webpack_require__(2);
45 exports
.OptionKind
= OptionKind
;
46 const defaultOptions
= {
49 kind
: OptionKind
.VIEWER
+ OptionKind
.PREFERENCE
52 value
: "compressed.tracemonkey-pldi-09.pdf",
53 kind
: OptionKind
.VIEWER
57 kind
: OptionKind
.VIEWER
+ OptionKind
.PREFERENCE
61 kind
: OptionKind
.VIEWER
65 kind
: OptionKind
.VIEWER
+ OptionKind
.PREFERENCE
69 kind
: OptionKind
.VIEWER
+ OptionKind
.PREFERENCE
71 enablePrintAutoRotate
: {
73 kind
: OptionKind
.VIEWER
+ OptionKind
.PREFERENCE
77 kind
: OptionKind
.VIEWER
+ OptionKind
.PREFERENCE
80 value
: "noopener noreferrer nofollow",
81 kind
: OptionKind
.VIEWER
85 kind
: OptionKind
.VIEWER
+ OptionKind
.PREFERENCE
89 kind
: OptionKind
.VIEWER
+ OptionKind
.PREFERENCE
91 ignoreDestinationZoom
: {
93 kind
: OptionKind
.VIEWER
+ OptionKind
.PREFERENCE
97 kind
: OptionKind
.VIEWER
101 compatibility
: _viewer_compatibility
.viewerCompatibilityParams
.maxCanvasPixels
,
102 kind
: OptionKind
.VIEWER
106 kind
: OptionKind
.VIEWER
+ OptionKind
.PREFERENCE
110 kind
: OptionKind
.VIEWER
114 kind
: OptionKind
.VIEWER
116 renderInteractiveForms
: {
118 kind
: OptionKind
.VIEWER
+ OptionKind
.PREFERENCE
122 kind
: OptionKind
.VIEWER
+ OptionKind
.PREFERENCE
126 kind
: OptionKind
.VIEWER
+ OptionKind
.PREFERENCE
130 kind
: OptionKind
.VIEWER
+ OptionKind
.PREFERENCE
134 kind
: OptionKind
.VIEWER
+ OptionKind
.PREFERENCE
138 kind
: OptionKind
.VIEWER
+ OptionKind
.PREFERENCE
142 kind
: OptionKind
.VIEWER
+ OptionKind
.PREFERENCE
146 kind
: OptionKind
.VIEWER
+ OptionKind
.PREFERENCE
153 value
: "../web/cmaps/",
158 kind
: OptionKind
.API
+ OptionKind
.PREFERENCE
162 kind
: OptionKind
.API
+ OptionKind
.PREFERENCE
166 kind
: OptionKind
.API
+ OptionKind
.PREFERENCE
170 kind
: OptionKind
.API
+ OptionKind
.PREFERENCE
178 kind
: OptionKind
.API
+ OptionKind
.PREFERENCE
180 fontExtraProperties
: {
196 standardFontDataUrl
: {
197 value
: "../web/standard_fonts/",
206 kind
: OptionKind
.WORKER
209 value
: "../build/pdf.worker.js",
210 kind
: OptionKind
.WORKER
214 defaultOptions
.disablePreferences
= {
216 kind
: OptionKind
.VIEWER
218 defaultOptions
.locale
= {
219 value
: typeof navigator
!== "undefined" ? navigator
.language
: "en-US",
220 kind
: OptionKind
.VIEWER
222 defaultOptions
.sandboxBundleSrc
= {
223 value
: "../build/pdf.sandbox.js",
224 kind
: OptionKind
.VIEWER
226 defaultOptions
.renderer
.kind
+= OptionKind
.PREFERENCE
;
228 const userOptions
= Object
.create(null);
232 throw new Error("Cannot initialize AppOptions.");
236 const userOption
= userOptions
[name
];
238 if (userOption
!== undefined) {
242 const defaultOption
= defaultOptions
[name
];
244 if (defaultOption
!== undefined) {
245 return defaultOption
.compatibility
?? defaultOption
.value
;
251 static getAll(kind
= null) {
252 const options
= Object
.create(null);
254 for (const name
in defaultOptions
) {
255 const defaultOption
= defaultOptions
[name
];
258 if ((kind
& defaultOption
.kind
) === 0) {
262 if (kind
=== OptionKind
.PREFERENCE
) {
263 const value
= defaultOption
.value
,
264 valueType
= typeof value
;
266 if (valueType
=== "boolean" || valueType
=== "string" || valueType
=== "number" && Number
.isInteger(value
)) {
267 options
[name
] = value
;
271 throw new Error(`Invalid type for preference: ${name}`);
275 const userOption
= userOptions
[name
];
276 options
[name
] = userOption
!== undefined ? userOption
: defaultOption
.compatibility
?? defaultOption
.value
;
282 static set(name
, value
) {
283 userOptions
[name
] = value
;
286 static setAll(options
) {
287 for (const name
in options
) {
288 userOptions
[name
] = options
[name
];
292 static remove(name
) {
293 delete userOptions
[name
];
298 exports
.AppOptions
= AppOptions
;
302 /***/ ((__unused_webpack_module
, exports
) => {
306 Object
.defineProperty(exports
, "__esModule", ({
309 exports
.viewerCompatibilityParams
= void 0;
310 const compatibilityParams
= Object
.create(null);
312 const userAgent
= typeof navigator
!== "undefined" && navigator
.userAgent
|| "";
313 const platform
= typeof navigator
!== "undefined" && navigator
.platform
|| "";
314 const maxTouchPoints
= typeof navigator
!== "undefined" && navigator
.maxTouchPoints
|| 1;
315 const isAndroid
= /Android/.test(userAgent
);
316 const isIOS
= /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent
) || platform
=== "MacIntel" && maxTouchPoints
> 1;
317 const isIOSChrome
= /CriOS/.test(userAgent
);
319 (function checkOnBlobSupport() {
321 compatibilityParams
.disableCreateObjectURL
= true;
325 (function checkCanvasSizeLimitation() {
326 if (isIOS
|| isAndroid
) {
327 compatibilityParams
.maxCanvasPixels
= 5242880;
331 const viewerCompatibilityParams
= Object
.freeze(compatibilityParams
);
332 exports
.viewerCompatibilityParams
= viewerCompatibilityParams
;
336 /***/ ((__unused_webpack_module
, exports
, __webpack_require__
) => {
340 Object
.defineProperty(exports
, "__esModule", ({
343 exports
.PDFViewerApplication
= exports
.PDFPrintServiceFactory
= exports
.DefaultExternalServices
= void 0;
345 var _ui_utils
= __webpack_require__(4);
347 var _app_options
= __webpack_require__(1);
349 var _pdfjsLib
= __webpack_require__(5);
351 var _pdf_cursor_tools
= __webpack_require__(6);
353 var _pdf_rendering_queue
= __webpack_require__(8);
355 var _overlay_manager
= __webpack_require__(9);
357 var _password_prompt
= __webpack_require__(10);
359 var _pdf_attachment_viewer
= __webpack_require__(11);
361 var _pdf_document_properties
= __webpack_require__(13);
363 var _pdf_find_bar
= __webpack_require__(14);
365 var _pdf_find_controller
= __webpack_require__(15);
367 var _pdf_history
= __webpack_require__(17);
369 var _pdf_layer_viewer
= __webpack_require__(18);
371 var _pdf_link_service
= __webpack_require__(19);
373 var _pdf_outline_viewer
= __webpack_require__(20);
375 var _pdf_presentation_mode
= __webpack_require__(21);
377 var _pdf_scripting_manager
= __webpack_require__(22);
379 var _pdf_sidebar
= __webpack_require__(23);
381 var _pdf_sidebar_resizer
= __webpack_require__(24);
383 var _pdf_thumbnail_viewer
= __webpack_require__(25);
385 var _pdf_viewer
= __webpack_require__(27);
387 var _secondary_toolbar
= __webpack_require__(35);
389 var _toolbar
= __webpack_require__(37);
391 var _viewer_compatibility
= __webpack_require__(2);
393 var _view_history
= __webpack_require__(38);
395 const DEFAULT_SCALE_DELTA
= 1.1;
396 const DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT
= 5000;
397 const FORCE_PAGES_LOADED_TIMEOUT
= 10000;
398 const WHEEL_ZOOM_DISABLED_TIMEOUT
= 1000;
399 const ENABLE_PERMISSIONS_CLASS
= "enablePermissions";
405 const ViewerCssTheme
= {
410 const KNOWN_VERSIONS
= ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "2.0", "2.1", "2.2", "2.3"];
411 const KNOWN_GENERATORS
= ["acrobat distiller", "acrobat pdfwriter", "adobe livecycle", "adobe pdf library", "adobe photoshop", "ghostscript", "tcpdf", "cairo", "dvipdfm", "dvips", "pdftex", "pdfkit", "itext", "prince", "quarkxpress", "mac os x", "microsoft", "openoffice", "oracle", "luradocument", "pdf-xchange", "antenna house", "aspose.cells", "fpdf"];
413 class DefaultExternalServices
{
415 throw new Error("Cannot initialize DefaultExternalServices.");
418 static updateFindControlState(data
) {}
420 static updateFindMatchesCount(data
) {}
422 static initPassiveLoading(callbacks
) {}
424 static async
fallback(data
) {}
426 static reportTelemetry(data
) {}
428 static createDownloadManager(options
) {
429 throw new Error("Not implemented: createDownloadManager");
432 static createPreferences() {
433 throw new Error("Not implemented: createPreferences");
436 static createL10n(options
) {
437 throw new Error("Not implemented: createL10n");
440 static createScripting(options
) {
441 throw new Error("Not implemented: createScripting");
444 static get supportsIntegratedFind() {
445 return (0, _pdfjsLib
.shadow
)(this, "supportsIntegratedFind", false);
448 static get supportsDocumentFonts() {
449 return (0, _pdfjsLib
.shadow
)(this, "supportsDocumentFonts", true);
452 static get supportedMouseWheelZoomModifierKeys() {
453 return (0, _pdfjsLib
.shadow
)(this, "supportedMouseWheelZoomModifierKeys", {
459 static get isInAutomation() {
460 return (0, _pdfjsLib
.shadow
)(this, "isInAutomation", false);
465 exports
.DefaultExternalServices
= DefaultExternalServices
;
466 const PDFViewerApplication
= {
467 initialBookmark
: document
.location
.hash
.substring(1),
468 _initializedCapability
: (0, _pdfjsLib
.createPromiseCapability
)(),
472 pdfLoadingTask
: null,
475 pdfThumbnailViewer
: null,
476 pdfRenderingQueue
: null,
477 pdfPresentationMode
: null,
478 pdfDocumentProperties
: null,
479 pdfLinkService
: null,
482 pdfSidebarResizer
: null,
483 pdfOutlineViewer
: null,
484 pdfAttachmentViewer
: null,
485 pdfLayerViewer
: null,
486 pdfCursorTools
: null,
487 pdfScriptingManager
: null,
489 downloadManager
: null,
490 overlayManager
: null,
493 secondaryToolbar
: null,
496 isInitialViewSet
: false,
497 downloadComplete
: false,
498 isViewerEmbedded
: window
.parent
!== window
,
501 externalServices
: DefaultExternalServices
,
502 _boundEvents
: Object
.create(null),
505 _contentDispositionFilename
: null,
506 _contentLength
: null,
507 _saveInProgress
: false,
508 _wheelUnusedTicks
: 0,
509 _idleCallbacks
: new Set(),
511 async
initialize(appConfig
) {
512 this.preferences
= this.externalServices
.createPreferences();
513 this.appConfig
= appConfig
;
514 await
this._readPreferences();
515 await
this._parseHashParameters();
517 this._forceCssTheme();
519 await
this._initializeL10n();
521 if (this.isViewerEmbedded
&& _app_options
.AppOptions
.get("externalLinkTarget") === _pdfjsLib
.LinkTarget
.NONE
) {
522 _app_options
.AppOptions
.set("externalLinkTarget", _pdfjsLib
.LinkTarget
.TOP
);
525 await
this._initializeViewerComponents();
527 this.bindWindowEvents();
528 const appContainer
= appConfig
.appContainer
|| document
.documentElement
;
529 this.l10n
.translate(appContainer
).then(() => {
530 this.eventBus
.dispatch("localized", {
535 this._initializedCapability
.resolve();
538 async
_readPreferences() {
539 if (_app_options
.AppOptions
.get("disablePreferences")) {
544 _app_options
.AppOptions
.setAll(await
this.preferences
.getAll());
546 console
.error(`_readPreferences: "${reason?.message}".`);
550 async
_parseHashParameters() {
551 if (!_app_options
.AppOptions
.get("pdfBugEnabled")) {
555 const hash
= document
.location
.hash
.substring(1);
561 const hashParams
= (0, _ui_utils
.parseQueryString
)(hash
),
564 if ("disableworker" in hashParams
&& hashParams
.disableworker
=== "true") {
565 waitOn
.push(loadFakeWorker());
568 if ("disablerange" in hashParams
) {
569 _app_options
.AppOptions
.set("disableRange", hashParams
.disablerange
=== "true");
572 if ("disablestream" in hashParams
) {
573 _app_options
.AppOptions
.set("disableStream", hashParams
.disablestream
=== "true");
576 if ("disableautofetch" in hashParams
) {
577 _app_options
.AppOptions
.set("disableAutoFetch", hashParams
.disableautofetch
=== "true");
580 if ("disablefontface" in hashParams
) {
581 _app_options
.AppOptions
.set("disableFontFace", hashParams
.disablefontface
=== "true");
584 if ("disablehistory" in hashParams
) {
585 _app_options
.AppOptions
.set("disableHistory", hashParams
.disablehistory
=== "true");
588 if ("verbosity" in hashParams
) {
589 _app_options
.AppOptions
.set("verbosity", hashParams
.verbosity
| 0);
592 if ("textlayer" in hashParams
) {
593 switch (hashParams
.textlayer
) {
595 _app_options
.AppOptions
.set("textLayerMode", _ui_utils
.TextLayerMode
.DISABLE
);
602 const viewer
= this.appConfig
.viewerContainer
;
603 viewer
.classList
.add("textLayer-" + hashParams
.textlayer
);
608 if ("pdfbug" in hashParams
) {
609 _app_options
.AppOptions
.set("pdfBug", true);
611 _app_options
.AppOptions
.set("fontExtraProperties", true);
613 const enabled
= hashParams
.pdfbug
.split(",");
614 waitOn
.push(loadAndEnablePDFBug(enabled
));
617 if ("locale" in hashParams
) {
618 _app_options
.AppOptions
.set("locale", hashParams
.locale
);
621 if (waitOn
.length
=== 0) {
625 return Promise
.all(waitOn
).catch(reason
=> {
626 console
.error(`_parseHashParameters: "${reason.message}".`);
630 async
_initializeL10n() {
631 this.l10n
= this.externalServices
.createL10n({
632 locale
: _app_options
.AppOptions
.get("locale")
634 const dir
= await
this.l10n
.getDirection();
635 document
.getElementsByTagName("html")[0].dir
= dir
;
639 const cssTheme
= _app_options
.AppOptions
.get("viewerCssTheme");
641 if (cssTheme
=== ViewerCssTheme
.AUTOMATIC
|| !Object
.values(ViewerCssTheme
).includes(cssTheme
)) {
646 const styleSheet
= document
.styleSheets
[0];
647 const cssRules
= styleSheet
?.cssRules
|| [];
648 const mediaMatcher
= "prefers-color-scheme";
649 const mediaRule
= `(${mediaMatcher}: dark)`;
650 const mediaRegex
= new RegExp(`^@media \\(${mediaMatcher}: dark\\) {\\n\\s*([\\w\\s-.,:;/\\\\{}()]+)\\n}$`);
652 for (let i
= 0, ii
= cssRules
.length
; i
< ii
; i
++) {
653 const rule
= cssRules
[i
];
655 if (rule
instanceof CSSMediaRule
&& rule
.media
?.[0] === mediaRule
) {
656 if (cssTheme
=== ViewerCssTheme
.LIGHT
) {
657 styleSheet
.deleteRule(i
);
661 const darkRules
= mediaRegex
.exec(rule
.cssText
);
663 if (darkRules
?.[1]) {
664 styleSheet
.deleteRule(i
);
665 styleSheet
.insertRule(darkRules
[1], i
);
672 console
.error(`_forceCssTheme: "${reason?.message}".`);
676 async
_initializeViewerComponents() {
677 const appConfig
= this.appConfig
;
678 const eventBus
= appConfig
.eventBus
|| new _ui_utils
.EventBus({
679 isInAutomation
: this.externalServices
.isInAutomation
681 this.eventBus
= eventBus
;
682 this.overlayManager
= new _overlay_manager
.OverlayManager();
683 const pdfRenderingQueue
= new _pdf_rendering_queue
.PDFRenderingQueue();
684 pdfRenderingQueue
.onIdle
= this._cleanup
.bind(this);
685 this.pdfRenderingQueue
= pdfRenderingQueue
;
686 const pdfLinkService
= new _pdf_link_service
.PDFLinkService({
688 externalLinkTarget
: _app_options
.AppOptions
.get("externalLinkTarget"),
689 externalLinkRel
: _app_options
.AppOptions
.get("externalLinkRel"),
690 ignoreDestinationZoom
: _app_options
.AppOptions
.get("ignoreDestinationZoom")
692 this.pdfLinkService
= pdfLinkService
;
693 const downloadManager
= this.externalServices
.createDownloadManager();
694 this.downloadManager
= downloadManager
;
695 const findController
= new _pdf_find_controller
.PDFFindController({
696 linkService
: pdfLinkService
,
699 this.findController
= findController
;
700 const pdfScriptingManager
= new _pdf_scripting_manager
.PDFScriptingManager({
702 sandboxBundleSrc
: _app_options
.AppOptions
.get("sandboxBundleSrc"),
703 scriptingFactory
: this.externalServices
,
704 docPropertiesLookup
: this._scriptingDocProperties
.bind(this)
706 this.pdfScriptingManager
= pdfScriptingManager
;
707 const container
= appConfig
.mainContainer
;
708 const viewer
= appConfig
.viewerContainer
;
709 this.pdfViewer
= new _pdf_viewer
.PDFViewer({
713 renderingQueue
: pdfRenderingQueue
,
714 linkService
: pdfLinkService
,
717 scriptingManager
: pdfScriptingManager
,
718 renderer
: _app_options
.AppOptions
.get("renderer"),
720 textLayerMode
: _app_options
.AppOptions
.get("textLayerMode"),
721 imageResourcesPath
: _app_options
.AppOptions
.get("imageResourcesPath"),
722 renderInteractiveForms
: _app_options
.AppOptions
.get("renderInteractiveForms"),
723 enablePrintAutoRotate
: _app_options
.AppOptions
.get("enablePrintAutoRotate"),
724 useOnlyCssZoom
: _app_options
.AppOptions
.get("useOnlyCssZoom"),
725 maxCanvasPixels
: _app_options
.AppOptions
.get("maxCanvasPixels"),
726 enableScripting
: _app_options
.AppOptions
.get("enableScripting")
728 pdfRenderingQueue
.setViewer(this.pdfViewer
);
729 pdfLinkService
.setViewer(this.pdfViewer
);
730 pdfScriptingManager
.setViewer(this.pdfViewer
);
731 this.pdfThumbnailViewer
= new _pdf_thumbnail_viewer
.PDFThumbnailViewer({
732 container
: appConfig
.sidebar
.thumbnailView
,
734 renderingQueue
: pdfRenderingQueue
,
735 linkService
: pdfLinkService
,
738 pdfRenderingQueue
.setThumbnailViewer(this.pdfThumbnailViewer
);
739 this.pdfHistory
= new _pdf_history
.PDFHistory({
740 linkService
: pdfLinkService
,
743 pdfLinkService
.setHistory(this.pdfHistory
);
745 if (!this.supportsIntegratedFind
) {
746 this.findBar
= new _pdf_find_bar
.PDFFindBar(appConfig
.findBar
, eventBus
, this.l10n
);
749 this.pdfDocumentProperties
= new _pdf_document_properties
.PDFDocumentProperties(appConfig
.documentProperties
, this.overlayManager
, eventBus
, this.l10n
);
750 this.pdfCursorTools
= new _pdf_cursor_tools
.PDFCursorTools({
753 cursorToolOnLoad
: _app_options
.AppOptions
.get("cursorToolOnLoad")
755 this.toolbar
= new _toolbar
.Toolbar(appConfig
.toolbar
, eventBus
, this.l10n
);
756 this.secondaryToolbar
= new _secondary_toolbar
.SecondaryToolbar(appConfig
.secondaryToolbar
, container
, eventBus
);
758 if (this.supportsFullscreen
) {
759 this.pdfPresentationMode
= new _pdf_presentation_mode
.PDFPresentationMode({
761 pdfViewer
: this.pdfViewer
,
766 this.passwordPrompt
= new _password_prompt
.PasswordPrompt(appConfig
.passwordOverlay
, this.overlayManager
, this.l10n
, this.isViewerEmbedded
);
767 this.pdfOutlineViewer
= new _pdf_outline_viewer
.PDFOutlineViewer({
768 container
: appConfig
.sidebar
.outlineView
,
770 linkService
: pdfLinkService
772 this.pdfAttachmentViewer
= new _pdf_attachment_viewer
.PDFAttachmentViewer({
773 container
: appConfig
.sidebar
.attachmentsView
,
777 this.pdfLayerViewer
= new _pdf_layer_viewer
.PDFLayerViewer({
778 container
: appConfig
.sidebar
.layersView
,
782 this.pdfSidebar
= new _pdf_sidebar
.PDFSidebar({
783 elements
: appConfig
.sidebar
,
784 pdfViewer
: this.pdfViewer
,
785 pdfThumbnailViewer
: this.pdfThumbnailViewer
,
789 this.pdfSidebar
.onToggled
= this.forceRendering
.bind(this);
790 this.pdfSidebarResizer
= new _pdf_sidebar_resizer
.PDFSidebarResizer(appConfig
.sidebarResizer
, eventBus
, this.l10n
);
794 this.initialize(config
).then(webViewerInitialized
);
798 return this._initializedCapability
.settled
;
801 get initializedPromise() {
802 return this._initializedCapability
.promise
;
806 if (this.pdfViewer
.isInPresentationMode
) {
810 let newScale
= this.pdfViewer
.currentScale
;
813 newScale
= (newScale
* DEFAULT_SCALE_DELTA
).toFixed(2);
814 newScale
= Math
.ceil(newScale
* 10) / 10;
815 newScale
= Math
.min(_ui_utils
.MAX_SCALE
, newScale
);
816 } while (--ticks
> 0 && newScale
< _ui_utils
.MAX_SCALE
);
818 this.pdfViewer
.currentScaleValue
= newScale
;
822 if (this.pdfViewer
.isInPresentationMode
) {
826 let newScale
= this.pdfViewer
.currentScale
;
829 newScale
= (newScale
/ DEFAULT_SCALE_DELTA
).toFixed(2);
830 newScale
= Math
.floor(newScale
* 10) / 10;
831 newScale
= Math
.max(_ui_utils
.MIN_SCALE
, newScale
);
832 } while (--ticks
> 0 && newScale
> _ui_utils
.MIN_SCALE
);
834 this.pdfViewer
.currentScaleValue
= newScale
;
838 if (this.pdfViewer
.isInPresentationMode
) {
842 this.pdfViewer
.currentScaleValue
= _ui_utils
.DEFAULT_SCALE_VALUE
;
846 return this.pdfDocument
? this.pdfDocument
.numPages
: 0;
850 return this.pdfViewer
.currentPageNumber
;
854 this.pdfViewer
.currentPageNumber
= val
;
857 get supportsPrinting() {
858 return PDFPrintServiceFactory
.instance
.supportsPrinting
;
861 get supportsFullscreen() {
862 const doc
= document
.documentElement
;
863 let support
= !!(doc
.requestFullscreen
|| doc
.mozRequestFullScreen
|| doc
.webkitRequestFullScreen
);
865 if (document
.fullscreenEnabled
=== false || document
.mozFullScreenEnabled
=== false || document
.webkitFullscreenEnabled
=== false) {
869 return (0, _pdfjsLib
.shadow
)(this, "supportsFullscreen", support
);
872 get supportsIntegratedFind() {
873 return this.externalServices
.supportsIntegratedFind
;
876 get supportsDocumentFonts() {
877 return this.externalServices
.supportsDocumentFonts
;
881 const bar
= new _ui_utils
.ProgressBar("#loadingBar");
882 return (0, _pdfjsLib
.shadow
)(this, "loadingBar", bar
);
885 get supportedMouseWheelZoomModifierKeys() {
886 return this.externalServices
.supportedMouseWheelZoomModifierKeys
;
889 initPassiveLoading() {
890 throw new Error("Not implemented: initPassiveLoading");
893 setTitleUsingUrl(url
= "") {
895 this.baseUrl
= url
.split("#")[0];
896 let title
= (0, _pdfjsLib
.getPdfFilenameFromUrl
)(url
, "");
900 title
= decodeURIComponent((0, _pdfjsLib
.getFilenameFromUrl
)(url
)) || url
;
906 this.setTitle(title
);
910 if (this.isViewerEmbedded
) {
914 document
.title
= title
;
918 return this._contentDispositionFilename
|| (0, _pdfjsLib
.getPdfFilenameFromUrl
)(this.url
);
921 _cancelIdleCallbacks() {
922 if (!this._idleCallbacks
.size
) {
926 for (const callback
of this._idleCallbacks
) {
927 window
.cancelIdleCallback(callback
);
930 this._idleCallbacks
.clear();
934 this._unblockDocumentLoadEvent();
938 } = this.appConfig
.errorWrapper
;
939 container
.hidden
= true;
941 if (!this.pdfLoadingTask
) {
945 if (this.pdfDocument
?.annotationStorage
.size
> 0 && this._annotationStorageModified
) {
948 sourceEventType
: "save"
954 promises
.push(this.pdfLoadingTask
.destroy());
955 this.pdfLoadingTask
= null;
957 if (this.pdfDocument
) {
958 this.pdfDocument
= null;
959 this.pdfThumbnailViewer
.setDocument(null);
960 this.pdfViewer
.setDocument(null);
961 this.pdfLinkService
.setDocument(null);
962 this.pdfDocumentProperties
.setDocument(null);
965 webViewerResetPermissions();
966 this.pdfLinkService
.externalLinkEnabled
= true;
967 this._fellback
= false;
969 this.isInitialViewSet
= false;
970 this.downloadComplete
= false;
973 this.documentInfo
= null;
974 this.metadata
= null;
975 this._contentDispositionFilename
= null;
976 this._contentLength
= null;
977 this._saveInProgress
= false;
979 this._cancelIdleCallbacks();
981 promises
.push(this.pdfScriptingManager
.destroyPromise
);
982 this.pdfSidebar
.reset();
983 this.pdfOutlineViewer
.reset();
984 this.pdfAttachmentViewer
.reset();
985 this.pdfLayerViewer
.reset();
987 if (this.pdfHistory
) {
988 this.pdfHistory
.reset();
992 this.findBar
.reset();
995 this.toolbar
.reset();
996 this.secondaryToolbar
.reset();
998 if (typeof PDFBug
!== "undefined") {
1002 await Promise
.all(promises
);
1005 async
open(file
, args
) {
1006 if (this.pdfLoadingTask
) {
1010 const workerParameters
= _app_options
.AppOptions
.getAll(_app_options
.OptionKind
.WORKER
);
1012 for (const key
in workerParameters
) {
1013 _pdfjsLib
.GlobalWorkerOptions
[key
] = workerParameters
[key
];
1016 const parameters
= Object
.create(null);
1018 if (typeof file
=== "string") {
1019 this.setTitleUsingUrl(file
);
1020 parameters
.url
= file
;
1021 } else if (file
&& "byteLength" in file
) {
1022 parameters
.data
= file
;
1023 } else if (file
.url
&& file
.originalUrl
) {
1024 this.setTitleUsingUrl(file
.originalUrl
);
1025 parameters
.url
= file
.url
;
1028 const apiParameters
= _app_options
.AppOptions
.getAll(_app_options
.OptionKind
.API
);
1030 for (const key
in apiParameters
) {
1031 let value
= apiParameters
[key
];
1033 if (key
=== "docBaseUrl" && !value
) {}
1035 parameters
[key
] = value
;
1039 for (const key
in args
) {
1040 parameters
[key
] = args
[key
];
1044 const loadingTask
= (0, _pdfjsLib
.getDocument
)(parameters
);
1045 this.pdfLoadingTask
= loadingTask
;
1047 loadingTask
.onPassword
= (updateCallback
, reason
) => {
1048 this.pdfLinkService
.externalLinkEnabled
= false;
1049 this.passwordPrompt
.setUpdateCallback(updateCallback
, reason
);
1050 this.passwordPrompt
.open();
1053 loadingTask
.onProgress
= ({
1057 this.progress(loaded
/ total
);
1060 loadingTask
.onUnsupportedFeature
= this.fallback
.bind(this);
1061 return loadingTask
.promise
.then(pdfDocument
=> {
1062 this.load(pdfDocument
);
1064 if (loadingTask
!== this.pdfLoadingTask
) {
1068 let key
= "loading_error";
1070 if (exception
instanceof _pdfjsLib
.InvalidPDFException
) {
1071 key
= "invalid_file_error";
1072 } else if (exception
instanceof _pdfjsLib
.MissingPDFException
) {
1073 key
= "missing_file_error";
1074 } else if (exception
instanceof _pdfjsLib
.UnexpectedResponseException
) {
1075 key
= "unexpected_response_error";
1078 return this.l10n
.get(key
).then(msg
=> {
1079 this._documentError(msg
, {
1080 message
: exception
?.message
1088 _ensureDownloadComplete() {
1089 if (this.pdfDocument
&& this.downloadComplete
) {
1093 throw new Error("PDF document not downloaded.");
1097 sourceEventType
= "download"
1099 const url
= this.baseUrl
,
1100 filename
= this._docFilename
;
1103 this._ensureDownloadComplete();
1105 const data
= await
this.pdfDocument
.getData();
1106 const blob
= new Blob([data
], {
1107 type
: "application/pdf"
1109 await
this.downloadManager
.download(blob
, url
, filename
, sourceEventType
);
1111 await
this.downloadManager
.downloadUrl(url
, filename
);
1116 sourceEventType
= "download"
1118 if (this._saveInProgress
) {
1122 this._saveInProgress
= true;
1123 await
this.pdfScriptingManager
.dispatchWillSave();
1124 const url
= this.baseUrl
,
1125 filename
= this._docFilename
;
1128 this._ensureDownloadComplete();
1130 const data
= await
this.pdfDocument
.saveDocument();
1131 const blob
= new Blob([data
], {
1132 type
: "application/pdf"
1134 await
this.downloadManager
.download(blob
, url
, filename
, sourceEventType
);
1136 await
this.download({
1140 await
this.pdfScriptingManager
.dispatchDidSave();
1141 this._saveInProgress
= false;
1145 downloadOrSave(options
) {
1146 if (this.pdfDocument
?.annotationStorage
.size
> 0) {
1149 this.download(options
);
1153 fallback(featureId
) {
1154 this.externalServices
.reportTelemetry({
1155 type
: "unsupportedFeature",
1159 if (this._fellback
) {
1163 this._fellback
= true;
1164 this.externalServices
.fallback({
1167 }).then(download
=> {
1173 sourceEventType
: "download"
1178 _documentError(message
, moreInfo
= null) {
1179 this._unblockDocumentLoadEvent();
1181 this._otherError(message
, moreInfo
);
1184 _otherError(message
, moreInfo
= null) {
1185 const moreInfoText
= [this.l10n
.get("error_version_info", {
1186 version
: _pdfjsLib
.version
|| "?",
1187 build
: _pdfjsLib
.build
|| "?"
1191 moreInfoText
.push(this.l10n
.get("error_message", {
1192 message
: moreInfo
.message
1195 if (moreInfo
.stack
) {
1196 moreInfoText
.push(this.l10n
.get("error_stack", {
1197 stack
: moreInfo
.stack
1200 if (moreInfo
.filename
) {
1201 moreInfoText
.push(this.l10n
.get("error_file", {
1202 file
: moreInfo
.filename
1206 if (moreInfo
.lineNumber
) {
1207 moreInfoText
.push(this.l10n
.get("error_line", {
1208 line
: moreInfo
.lineNumber
1214 const errorWrapperConfig
= this.appConfig
.errorWrapper
;
1215 const errorWrapper
= errorWrapperConfig
.container
;
1216 errorWrapper
.hidden
= false;
1217 const errorMessage
= errorWrapperConfig
.errorMessage
;
1218 errorMessage
.textContent
= message
;
1219 const closeButton
= errorWrapperConfig
.closeButton
;
1221 closeButton
.onclick = function () {
1222 errorWrapper
.hidden
= true;
1225 const errorMoreInfo
= errorWrapperConfig
.errorMoreInfo
;
1226 const moreInfoButton
= errorWrapperConfig
.moreInfoButton
;
1227 const lessInfoButton
= errorWrapperConfig
.lessInfoButton
;
1229 moreInfoButton
.onclick = function () {
1230 errorMoreInfo
.hidden
= false;
1231 moreInfoButton
.hidden
= true;
1232 lessInfoButton
.hidden
= false;
1233 errorMoreInfo
.style
.height
= errorMoreInfo
.scrollHeight
+ "px";
1236 lessInfoButton
.onclick = function () {
1237 errorMoreInfo
.hidden
= true;
1238 moreInfoButton
.hidden
= false;
1239 lessInfoButton
.hidden
= true;
1242 moreInfoButton
.oncontextmenu
= _ui_utils
.noContextMenuHandler
;
1243 lessInfoButton
.oncontextmenu
= _ui_utils
.noContextMenuHandler
;
1244 closeButton
.oncontextmenu
= _ui_utils
.noContextMenuHandler
;
1245 moreInfoButton
.hidden
= false;
1246 lessInfoButton
.hidden
= true;
1247 Promise
.all(moreInfoText
).then(parts
=> {
1248 errorMoreInfo
.value
= parts
.join("\n");
1253 if (this.downloadComplete
) {
1257 const percent
= Math
.round(level
* 100);
1259 if (percent
> this.loadingBar
.percent
|| isNaN(percent
)) {
1260 this.loadingBar
.percent
= percent
;
1261 const disableAutoFetch
= this.pdfDocument
? this.pdfDocument
.loadingParams
.disableAutoFetch
: _app_options
.AppOptions
.get("disableAutoFetch");
1263 if (disableAutoFetch
&& percent
) {
1264 if (this.disableAutoFetchLoadingBarTimeout
) {
1265 clearTimeout(this.disableAutoFetchLoadingBarTimeout
);
1266 this.disableAutoFetchLoadingBarTimeout
= null;
1269 this.loadingBar
.show();
1270 this.disableAutoFetchLoadingBarTimeout
= setTimeout(() => {
1271 this.loadingBar
.hide();
1272 this.disableAutoFetchLoadingBarTimeout
= null;
1273 }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT
);
1279 this.pdfDocument
= pdfDocument
;
1280 pdfDocument
.getDownloadInfo().then(({
1283 this._contentLength
= length
;
1284 this.downloadComplete
= true;
1285 this.loadingBar
.hide();
1286 firstPagePromise
.then(() => {
1287 this.eventBus
.dispatch("documentloaded", {
1292 const pageLayoutPromise
= pdfDocument
.getPageLayout().catch(function () {});
1293 const pageModePromise
= pdfDocument
.getPageMode().catch(function () {});
1294 const openActionPromise
= pdfDocument
.getOpenAction().catch(function () {});
1295 this.toolbar
.setPagesCount(pdfDocument
.numPages
, false);
1296 this.secondaryToolbar
.setPagesCount(pdfDocument
.numPages
);
1297 let baseDocumentUrl
;
1298 baseDocumentUrl
= null;
1299 this.pdfLinkService
.setDocument(pdfDocument
, baseDocumentUrl
);
1300 this.pdfDocumentProperties
.setDocument(pdfDocument
, this.url
);
1301 const pdfViewer
= this.pdfViewer
;
1302 pdfViewer
.setDocument(pdfDocument
);
1308 const pdfThumbnailViewer
= this.pdfThumbnailViewer
;
1309 pdfThumbnailViewer
.setDocument(pdfDocument
);
1310 const storedPromise
= (this.store
= new _view_history
.ViewHistory(pdfDocument
.fingerprints
[0])).getMultiple({
1312 zoom
: _ui_utils
.DEFAULT_SCALE_VALUE
,
1316 sidebarView
: _ui_utils
.SidebarView
.UNKNOWN
,
1317 scrollMode
: _ui_utils
.ScrollMode
.UNKNOWN
,
1318 spreadMode
: _ui_utils
.SpreadMode
.UNKNOWN
1320 return Object
.create(null);
1322 firstPagePromise
.then(pdfPage
=> {
1323 this.loadingBar
.setWidth(this.appConfig
.viewerContainer
);
1325 this._initializeAnnotationStorageCallbacks(pdfDocument
);
1327 Promise
.all([_ui_utils
.animationStarted
, storedPromise
, pageLayoutPromise
, pageModePromise
, openActionPromise
]).then(async ([timeStamp
, stored
, pageLayout
, pageMode
, openAction
]) => {
1328 const viewOnLoad
= _app_options
.AppOptions
.get("viewOnLoad");
1330 this._initializePdfHistory({
1331 fingerprint
: pdfDocument
.fingerprints
[0],
1333 initialDest
: openAction
?.dest
1336 const initialBookmark
= this.initialBookmark
;
1338 const zoom
= _app_options
.AppOptions
.get("defaultZoomValue");
1340 let hash
= zoom
? `zoom=${zoom}` : null;
1341 let rotation
= null;
1343 let sidebarView
= _app_options
.AppOptions
.get("sidebarViewOnLoad");
1345 let scrollMode
= _app_options
.AppOptions
.get("scrollModeOnLoad");
1347 let spreadMode
= _app_options
.AppOptions
.get("spreadModeOnLoad");
1349 if (stored
.page
&& viewOnLoad
!== ViewOnLoad
.INITIAL
) {
1350 hash
= `page=${stored.page}&zoom=${zoom || stored.zoom},` + `${stored.scrollLeft},${stored.scrollTop}`;
1351 rotation
= parseInt(stored
.rotation
, 10);
1353 if (sidebarView
=== _ui_utils
.SidebarView
.UNKNOWN
) {
1354 sidebarView
= stored
.sidebarView
| 0;
1357 if (scrollMode
=== _ui_utils
.ScrollMode
.UNKNOWN
) {
1358 scrollMode
= stored
.scrollMode
| 0;
1361 if (spreadMode
=== _ui_utils
.SpreadMode
.UNKNOWN
) {
1362 spreadMode
= stored
.spreadMode
| 0;
1366 if (pageMode
&& sidebarView
=== _ui_utils
.SidebarView
.UNKNOWN
) {
1367 sidebarView
= (0, _ui_utils
.apiPageModeToSidebarView
)(pageMode
);
1370 if (pageLayout
&& spreadMode
=== _ui_utils
.SpreadMode
.UNKNOWN
) {
1371 spreadMode
= (0, _ui_utils
.apiPageLayoutToSpreadMode
)(pageLayout
);
1374 this.setInitialView(hash
, {
1380 this.eventBus
.dispatch("documentinit", {
1384 if (!this.isViewerEmbedded
) {
1388 this._initializePermissions(pdfDocument
);
1390 await Promise
.race([pagesPromise
, new Promise(resolve
=> {
1391 setTimeout(resolve
, FORCE_PAGES_LOADED_TIMEOUT
);
1394 if (!initialBookmark
&& !hash
) {
1398 if (pdfViewer
.hasEqualPageSizes
) {
1402 this.initialBookmark
= initialBookmark
;
1403 pdfViewer
.currentScaleValue
= pdfViewer
.currentScaleValue
;
1404 this.setInitialView(hash
);
1406 this.setInitialView();
1407 }).then(function () {
1411 pagesPromise
.then(() => {
1412 this._unblockDocumentLoadEvent();
1414 this._initializeAutoPrint(pdfDocument
, openActionPromise
);
1416 onePageRendered
.then(() => {
1417 pdfDocument
.getOutline().then(outline
=> {
1418 if (pdfDocument
!== this.pdfDocument
) {
1422 this.pdfOutlineViewer
.render({
1427 pdfDocument
.getAttachments().then(attachments
=> {
1428 if (pdfDocument
!== this.pdfDocument
) {
1432 this.pdfAttachmentViewer
.render({
1436 pdfViewer
.optionalContentConfigPromise
.then(optionalContentConfig
=> {
1437 if (pdfDocument
!== this.pdfDocument
) {
1441 this.pdfLayerViewer
.render({
1442 optionalContentConfig
,
1447 if ("requestIdleCallback" in window
) {
1448 const callback
= window
.requestIdleCallback(() => {
1449 this._collectTelemetry(pdfDocument
);
1451 this._idleCallbacks
.delete(callback
);
1456 this._idleCallbacks
.add(callback
);
1460 this._initializePageLabels(pdfDocument
);
1462 this._initializeMetadata(pdfDocument
);
1465 async
_scriptingDocProperties(pdfDocument
) {
1466 if (!this.documentInfo
) {
1467 await
new Promise(resolve
=> {
1468 this.eventBus
._on("metadataloaded", resolve
, {
1473 if (pdfDocument
!== this.pdfDocument
) {
1478 if (!this._contentLength
) {
1479 await
new Promise(resolve
=> {
1480 this.eventBus
._on("documentloaded", resolve
, {
1485 if (pdfDocument
!== this.pdfDocument
) {
1490 return { ...this.documentInfo
,
1491 baseURL
: this.baseUrl
,
1492 filesize
: this._contentLength
,
1493 filename
: this._docFilename
,
1494 metadata
: this.metadata
?.getRaw(),
1495 authors
: this.metadata
?.get("dc:creator"),
1496 numPages
: this.pagesCount
,
1501 async
_collectTelemetry(pdfDocument
) {
1502 const markInfo
= await
this.pdfDocument
.getMarkInfo();
1504 if (pdfDocument
!== this.pdfDocument
) {
1508 const tagged
= markInfo
?.Marked
|| false;
1509 this.externalServices
.reportTelemetry({
1515 async
_initializeAutoPrint(pdfDocument
, openActionPromise
) {
1516 const [openAction
, javaScript
] = await Promise
.all([openActionPromise
, !this.pdfViewer
.enableScripting
? pdfDocument
.getJavaScript() : null]);
1518 if (pdfDocument
!== this.pdfDocument
) {
1522 let triggerAutoPrint
= false;
1524 if (openAction
?.action
=== "Print") {
1525 triggerAutoPrint
= true;
1529 javaScript
.some(js
=> {
1534 console
.warn("Warning: JavaScript support is not enabled");
1535 this.fallback(_pdfjsLib
.UNSUPPORTED_FEATURES
.javaScript
);
1539 if (!triggerAutoPrint
) {
1540 for (const js
of javaScript
) {
1541 if (js
&& _ui_utils
.AutoPrintRegExp
.test(js
)) {
1542 triggerAutoPrint
= true;
1549 if (triggerAutoPrint
) {
1550 this.triggerPrinting();
1554 async
_initializeMetadata(pdfDocument
) {
1558 contentDispositionFilename
,
1560 } = await pdfDocument
.getMetadata();
1562 if (pdfDocument
!== this.pdfDocument
) {
1566 this.documentInfo
= info
;
1567 this.metadata
= metadata
;
1568 this._contentDispositionFilename
?? (this._contentDispositionFilename
= contentDispositionFilename
);
1569 this._contentLength
?? (this._contentLength
= contentLength
);
1570 console
.log(`PDF ${pdfDocument.fingerprints[0]} [${info.PDFFormatVersion} ` + `${(info.Producer || "-").trim()} / ${(info.Creator || "-").trim()}] ` + `(PDF.js: ${_pdfjsLib.version || "-"})`);
1571 let pdfTitle
= info
?.Title
;
1572 const metadataTitle
= metadata
?.get("dc:title");
1574 if (metadataTitle
) {
1575 if (metadataTitle
!== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(metadataTitle
)) {
1576 pdfTitle
= metadataTitle
;
1581 this.setTitle(`${pdfTitle} - ${contentDispositionFilename || document.title}`);
1582 } else if (contentDispositionFilename
) {
1583 this.setTitle(contentDispositionFilename
);
1586 if (info
.IsXFAPresent
&& !info
.IsAcroFormPresent
&& !pdfDocument
.isPureXfa
) {
1587 console
.warn("Warning: XFA support is not enabled");
1588 this.fallback(_pdfjsLib
.UNSUPPORTED_FEATURES
.forms
);
1589 } else if ((info
.IsAcroFormPresent
|| info
.IsXFAPresent
) && !this.pdfViewer
.renderInteractiveForms
) {
1590 console
.warn("Warning: Interactive form support is not enabled");
1591 this.fallback(_pdfjsLib
.UNSUPPORTED_FEATURES
.forms
);
1594 if (info
.IsSignaturesPresent
) {
1595 console
.warn("Warning: Digital signatures validation is not supported");
1596 this.fallback(_pdfjsLib
.UNSUPPORTED_FEATURES
.signatures
);
1599 let versionId
= "other";
1601 if (KNOWN_VERSIONS
.includes(info
.PDFFormatVersion
)) {
1602 versionId
= `v${info.PDFFormatVersion.replace(".", "_")}`;
1605 let generatorId
= "other";
1607 if (info
.Producer
) {
1608 const producer
= info
.Producer
.toLowerCase();
1609 KNOWN_GENERATORS
.some(function (generator
) {
1610 if (!producer
.includes(generator
)) {
1614 generatorId
= generator
.replace(/[ .-]/g, "_");
1619 let formType
= null;
1621 if (info
.IsXFAPresent
) {
1623 } else if (info
.IsAcroFormPresent
) {
1624 formType
= "acroform";
1627 this.externalServices
.reportTelemetry({
1628 type
: "documentInfo",
1630 generator
: generatorId
,
1633 this.eventBus
.dispatch("metadataloaded", {
1638 async
_initializePageLabels(pdfDocument
) {
1639 const labels
= await pdfDocument
.getPageLabels();
1641 if (pdfDocument
!== this.pdfDocument
) {
1645 if (!labels
|| _app_options
.AppOptions
.get("disablePageLabels")) {
1649 const numLabels
= labels
.length
;
1651 if (numLabels
!== this.pagesCount
) {
1652 console
.error("The number of Page Labels does not match the number of pages in the document.");
1658 while (i
< numLabels
&& labels
[i
] === (i
+ 1).toString()) {
1662 if (i
=== numLabels
) {
1671 pdfViewer
.setPageLabels(labels
);
1672 pdfThumbnailViewer
.setPageLabels(labels
);
1673 toolbar
.setPagesCount(numLabels
, true);
1674 toolbar
.setPageNumber(pdfViewer
.currentPageNumber
, pdfViewer
.currentPageLabel
);
1677 _initializePdfHistory({
1682 if (this.isViewerEmbedded
|| _app_options
.AppOptions
.get("disableHistory")) {
1686 this.pdfHistory
.initialize({
1688 resetHistory
: viewOnLoad
=== ViewOnLoad
.INITIAL
,
1689 updateUrl
: _app_options
.AppOptions
.get("historyUpdateUrl")
1692 if (this.pdfHistory
.initialBookmark
) {
1693 this.initialBookmark
= this.pdfHistory
.initialBookmark
;
1694 this.initialRotation
= this.pdfHistory
.initialRotation
;
1697 if (initialDest
&& !this.initialBookmark
&& viewOnLoad
=== ViewOnLoad
.UNKNOWN
) {
1698 this.initialBookmark
= JSON
.stringify(initialDest
);
1699 this.pdfHistory
.push({
1700 explicitDest
: initialDest
,
1706 async
_initializePermissions(pdfDocument
) {
1707 const permissions
= await pdfDocument
.getPermissions();
1709 if (pdfDocument
!== this.pdfDocument
) {
1713 if (!permissions
|| !_app_options
.AppOptions
.get("enablePermissions")) {
1717 if (!permissions
.includes(_pdfjsLib
.PermissionFlag
.COPY
)) {
1718 this.appConfig
.viewerContainer
.classList
.add(ENABLE_PERMISSIONS_CLASS
);
1722 _initializeAnnotationStorageCallbacks(pdfDocument
) {
1723 if (pdfDocument
!== this.pdfDocument
) {
1731 annotationStorage
.onSetModified
= () => {
1732 window
.addEventListener("beforeunload", beforeUnload
);
1733 this._annotationStorageModified
= true;
1736 annotationStorage
.onResetModified
= () => {
1737 window
.removeEventListener("beforeunload", beforeUnload
);
1738 delete this._annotationStorageModified
;
1742 setInitialView(storedHash
, {
1748 const setRotation
= angle
=> {
1749 if ((0, _ui_utils
.isValidRotation
)(angle
)) {
1750 this.pdfViewer
.pagesRotation
= angle
;
1754 const setViewerModes
= (scroll
, spread
) => {
1755 if ((0, _ui_utils
.isValidScrollMode
)(scroll
)) {
1756 this.pdfViewer
.scrollMode
= scroll
;
1759 if ((0, _ui_utils
.isValidSpreadMode
)(spread
)) {
1760 this.pdfViewer
.spreadMode
= spread
;
1764 this.isInitialViewSet
= true;
1765 this.pdfSidebar
.setInitialView(sidebarView
);
1766 setViewerModes(scrollMode
, spreadMode
);
1768 if (this.initialBookmark
) {
1769 setRotation(this.initialRotation
);
1770 delete this.initialRotation
;
1771 this.pdfLinkService
.setHash(this.initialBookmark
);
1772 this.initialBookmark
= null;
1773 } else if (storedHash
) {
1774 setRotation(rotation
);
1775 this.pdfLinkService
.setHash(storedHash
);
1778 this.toolbar
.setPageNumber(this.pdfViewer
.currentPageNumber
, this.pdfViewer
.currentPageLabel
);
1779 this.secondaryToolbar
.setPageNumber(this.pdfViewer
.currentPageNumber
);
1781 if (!this.pdfViewer
.currentScaleValue
) {
1782 this.pdfViewer
.currentScaleValue
= _ui_utils
.DEFAULT_SCALE_VALUE
;
1787 if (!this.pdfDocument
) {
1791 this.pdfViewer
.cleanup();
1792 this.pdfThumbnailViewer
.cleanup();
1793 this.pdfDocument
.cleanup(this.pdfViewer
.renderer
=== _ui_utils
.RendererType
.SVG
);
1797 this.pdfRenderingQueue
.printing
= !!this.printService
;
1798 this.pdfRenderingQueue
.isThumbnailViewEnabled
= this.pdfSidebar
.isThumbnailViewVisible
;
1799 this.pdfRenderingQueue
.renderHighestPriority();
1803 this.pdfScriptingManager
.dispatchWillPrint();
1805 if (this.printService
) {
1809 if (!this.supportsPrinting
) {
1810 this.l10n
.get("printing_not_supported").then(msg
=> {
1811 this._otherError(msg
);
1816 if (!this.pdfViewer
.pageViewsReady
) {
1817 this.l10n
.get("printing_not_ready").then(msg
=> {
1823 const pagesOverview
= this.pdfViewer
.getPagesOverview();
1824 const printContainer
= this.appConfig
.printContainer
;
1826 const printResolution
= _app_options
.AppOptions
.get("printResolution");
1828 const optionalContentConfigPromise
= this.pdfViewer
.optionalContentConfigPromise
;
1829 const printService
= PDFPrintServiceFactory
.instance
.createPrintService(this.pdfDocument
, pagesOverview
, printContainer
, printResolution
, optionalContentConfigPromise
, this.l10n
);
1830 this.printService
= printService
;
1831 this.forceRendering();
1832 printService
.layout();
1833 this.externalServices
.reportTelemetry({
1839 this.pdfScriptingManager
.dispatchDidPrint();
1841 if (this.printService
) {
1842 this.printService
.destroy();
1843 this.printService
= null;
1845 if (this.pdfDocument
) {
1846 this.pdfDocument
.annotationStorage
.resetModified();
1850 this.forceRendering();
1853 rotatePages(delta
) {
1854 this.pdfViewer
.pagesRotation
+= delta
;
1857 requestPresentationMode() {
1858 if (!this.pdfPresentationMode
) {
1862 this.pdfPresentationMode
.request();
1866 if (!this.supportsPrinting
) {
1878 _boundEvents
.beforePrint
= this.beforePrint
.bind(this);
1879 _boundEvents
.afterPrint
= this.afterPrint
.bind(this);
1881 eventBus
._on("resize", webViewerResize
);
1883 eventBus
._on("hashchange", webViewerHashchange
);
1885 eventBus
._on("beforeprint", _boundEvents
.beforePrint
);
1887 eventBus
._on("afterprint", _boundEvents
.afterPrint
);
1889 eventBus
._on("pagerendered", webViewerPageRendered
);
1891 eventBus
._on("updateviewarea", webViewerUpdateViewarea
);
1893 eventBus
._on("pagechanging", webViewerPageChanging
);
1895 eventBus
._on("scalechanging", webViewerScaleChanging
);
1897 eventBus
._on("rotationchanging", webViewerRotationChanging
);
1899 eventBus
._on("sidebarviewchanged", webViewerSidebarViewChanged
);
1901 eventBus
._on("pagemode", webViewerPageMode
);
1903 eventBus
._on("namedaction", webViewerNamedAction
);
1905 eventBus
._on("presentationmodechanged", webViewerPresentationModeChanged
);
1907 eventBus
._on("presentationmode", webViewerPresentationMode
);
1909 eventBus
._on("print", webViewerPrint
);
1911 eventBus
._on("download", webViewerDownload
);
1913 eventBus
._on("save", webViewerSave
);
1915 eventBus
._on("firstpage", webViewerFirstPage
);
1917 eventBus
._on("lastpage", webViewerLastPage
);
1919 eventBus
._on("nextpage", webViewerNextPage
);
1921 eventBus
._on("previouspage", webViewerPreviousPage
);
1923 eventBus
._on("zoomin", webViewerZoomIn
);
1925 eventBus
._on("zoomout", webViewerZoomOut
);
1927 eventBus
._on("zoomreset", webViewerZoomReset
);
1929 eventBus
._on("pagenumberchanged", webViewerPageNumberChanged
);
1931 eventBus
._on("scalechanged", webViewerScaleChanged
);
1933 eventBus
._on("rotatecw", webViewerRotateCw
);
1935 eventBus
._on("rotateccw", webViewerRotateCcw
);
1937 eventBus
._on("optionalcontentconfig", webViewerOptionalContentConfig
);
1939 eventBus
._on("switchscrollmode", webViewerSwitchScrollMode
);
1941 eventBus
._on("scrollmodechanged", webViewerScrollModeChanged
);
1943 eventBus
._on("switchspreadmode", webViewerSwitchSpreadMode
);
1945 eventBus
._on("spreadmodechanged", webViewerSpreadModeChanged
);
1947 eventBus
._on("documentproperties", webViewerDocumentProperties
);
1949 eventBus
._on("find", webViewerFind
);
1951 eventBus
._on("findfromurlhash", webViewerFindFromUrlHash
);
1953 eventBus
._on("updatefindmatchescount", webViewerUpdateFindMatchesCount
);
1955 eventBus
._on("updatefindcontrolstate", webViewerUpdateFindControlState
);
1957 if (_app_options
.AppOptions
.get("pdfBug")) {
1958 _boundEvents
.reportPageStatsPDFBug
= reportPageStatsPDFBug
;
1960 eventBus
._on("pagerendered", _boundEvents
.reportPageStatsPDFBug
);
1962 eventBus
._on("pagechanging", _boundEvents
.reportPageStatsPDFBug
);
1965 eventBus
._on("fileinputchange", webViewerFileInputChange
);
1967 eventBus
._on("openfile", webViewerOpenFile
);
1970 bindWindowEvents() {
1976 _boundEvents
.windowResize
= () => {
1977 eventBus
.dispatch("resize", {
1982 _boundEvents
.windowHashChange
= () => {
1983 eventBus
.dispatch("hashchange", {
1985 hash
: document
.location
.hash
.substring(1)
1989 _boundEvents
.windowBeforePrint
= () => {
1990 eventBus
.dispatch("beforeprint", {
1995 _boundEvents
.windowAfterPrint
= () => {
1996 eventBus
.dispatch("afterprint", {
2001 _boundEvents
.windowUpdateFromSandbox
= event
=> {
2002 eventBus
.dispatch("updatefromsandbox", {
2004 detail
: event
.detail
2008 window
.addEventListener("visibilitychange", webViewerVisibilityChange
);
2009 window
.addEventListener("wheel", webViewerWheel
, {
2012 window
.addEventListener("touchstart", webViewerTouchStart
, {
2015 window
.addEventListener("click", webViewerClick
);
2016 window
.addEventListener("keydown", webViewerKeyDown
);
2017 window
.addEventListener("resize", _boundEvents
.windowResize
);
2018 window
.addEventListener("hashchange", _boundEvents
.windowHashChange
);
2019 window
.addEventListener("beforeprint", _boundEvents
.windowBeforePrint
);
2020 window
.addEventListener("afterprint", _boundEvents
.windowAfterPrint
);
2021 window
.addEventListener("updatefromsandbox", _boundEvents
.windowUpdateFromSandbox
);
2030 eventBus
._off("resize", webViewerResize
);
2032 eventBus
._off("hashchange", webViewerHashchange
);
2034 eventBus
._off("beforeprint", _boundEvents
.beforePrint
);
2036 eventBus
._off("afterprint", _boundEvents
.afterPrint
);
2038 eventBus
._off("pagerendered", webViewerPageRendered
);
2040 eventBus
._off("updateviewarea", webViewerUpdateViewarea
);
2042 eventBus
._off("pagechanging", webViewerPageChanging
);
2044 eventBus
._off("scalechanging", webViewerScaleChanging
);
2046 eventBus
._off("rotationchanging", webViewerRotationChanging
);
2048 eventBus
._off("sidebarviewchanged", webViewerSidebarViewChanged
);
2050 eventBus
._off("pagemode", webViewerPageMode
);
2052 eventBus
._off("namedaction", webViewerNamedAction
);
2054 eventBus
._off("presentationmodechanged", webViewerPresentationModeChanged
);
2056 eventBus
._off("presentationmode", webViewerPresentationMode
);
2058 eventBus
._off("print", webViewerPrint
);
2060 eventBus
._off("download", webViewerDownload
);
2062 eventBus
._off("save", webViewerSave
);
2064 eventBus
._off("firstpage", webViewerFirstPage
);
2066 eventBus
._off("lastpage", webViewerLastPage
);
2068 eventBus
._off("nextpage", webViewerNextPage
);
2070 eventBus
._off("previouspage", webViewerPreviousPage
);
2072 eventBus
._off("zoomin", webViewerZoomIn
);
2074 eventBus
._off("zoomout", webViewerZoomOut
);
2076 eventBus
._off("zoomreset", webViewerZoomReset
);
2078 eventBus
._off("pagenumberchanged", webViewerPageNumberChanged
);
2080 eventBus
._off("scalechanged", webViewerScaleChanged
);
2082 eventBus
._off("rotatecw", webViewerRotateCw
);
2084 eventBus
._off("rotateccw", webViewerRotateCcw
);
2086 eventBus
._off("optionalcontentconfig", webViewerOptionalContentConfig
);
2088 eventBus
._off("switchscrollmode", webViewerSwitchScrollMode
);
2090 eventBus
._off("scrollmodechanged", webViewerScrollModeChanged
);
2092 eventBus
._off("switchspreadmode", webViewerSwitchSpreadMode
);
2094 eventBus
._off("spreadmodechanged", webViewerSpreadModeChanged
);
2096 eventBus
._off("documentproperties", webViewerDocumentProperties
);
2098 eventBus
._off("find", webViewerFind
);
2100 eventBus
._off("findfromurlhash", webViewerFindFromUrlHash
);
2102 eventBus
._off("updatefindmatchescount", webViewerUpdateFindMatchesCount
);
2104 eventBus
._off("updatefindcontrolstate", webViewerUpdateFindControlState
);
2106 if (_boundEvents
.reportPageStatsPDFBug
) {
2107 eventBus
._off("pagerendered", _boundEvents
.reportPageStatsPDFBug
);
2109 eventBus
._off("pagechanging", _boundEvents
.reportPageStatsPDFBug
);
2111 _boundEvents
.reportPageStatsPDFBug
= null;
2114 eventBus
._off("fileinputchange", webViewerFileInputChange
);
2116 eventBus
._off("openfile", webViewerOpenFile
);
2118 _boundEvents
.beforePrint
= null;
2119 _boundEvents
.afterPrint
= null;
2122 unbindWindowEvents() {
2126 window
.removeEventListener("visibilitychange", webViewerVisibilityChange
);
2127 window
.removeEventListener("wheel", webViewerWheel
, {
2130 window
.removeEventListener("touchstart", webViewerTouchStart
, {
2133 window
.removeEventListener("click", webViewerClick
);
2134 window
.removeEventListener("keydown", webViewerKeyDown
);
2135 window
.removeEventListener("resize", _boundEvents
.windowResize
);
2136 window
.removeEventListener("hashchange", _boundEvents
.windowHashChange
);
2137 window
.removeEventListener("beforeprint", _boundEvents
.windowBeforePrint
);
2138 window
.removeEventListener("afterprint", _boundEvents
.windowAfterPrint
);
2139 window
.removeEventListener("updatefromsandbox", _boundEvents
.windowUpdateFromSandbox
);
2140 _boundEvents
.windowResize
= null;
2141 _boundEvents
.windowHashChange
= null;
2142 _boundEvents
.windowBeforePrint
= null;
2143 _boundEvents
.windowAfterPrint
= null;
2144 _boundEvents
.windowUpdateFromSandbox
= null;
2147 accumulateWheelTicks(ticks
) {
2148 if (this._wheelUnusedTicks
> 0 && ticks
< 0 || this._wheelUnusedTicks
< 0 && ticks
> 0) {
2149 this._wheelUnusedTicks
= 0;
2152 this._wheelUnusedTicks
+= ticks
;
2153 const wholeTicks
= Math
.sign(this._wheelUnusedTicks
) * Math
.floor(Math
.abs(this._wheelUnusedTicks
));
2154 this._wheelUnusedTicks
-= wholeTicks
;
2158 _unblockDocumentLoadEvent() {
2159 if (document
.blockUnblockOnload
) {
2160 document
.blockUnblockOnload(false);
2163 this._unblockDocumentLoadEvent
= () => {};
2166 get scriptingReady() {
2167 return this.pdfScriptingManager
.ready
;
2171 exports
.PDFViewerApplication
= PDFViewerApplication
;
2172 let validateFileURL = function (file
) {return;};
2174 async
function loadFakeWorker() {
2175 if (!_pdfjsLib
.GlobalWorkerOptions
.workerSrc
) {
2176 _pdfjsLib
.GlobalWorkerOptions
.workerSrc
= _app_options
.AppOptions
.get("workerSrc");
2179 return (0, _pdfjsLib
.loadScript
)(_pdfjsLib
.PDFWorker
.getWorkerSrc());
2182 function loadAndEnablePDFBug(enabledTabs
) {
2183 const appConfig
= PDFViewerApplication
.appConfig
;
2184 return (0, _pdfjsLib
.loadScript
)(appConfig
.debuggerScriptPath
).then(function () {
2185 PDFBug
.enable(enabledTabs
);
2188 }, appConfig
.mainContainer
);
2192 function reportPageStatsPDFBug({
2195 if (typeof Stats
=== "undefined" || !Stats
.enabled
) {
2199 const pageView
= PDFViewerApplication
.pdfViewer
.getPageView(pageNumber
- 1);
2200 const pageStats
= pageView
?.pdfPage
?.stats
;
2206 Stats
.add(pageNumber
, pageStats
);
2209 function webViewerInitialized() {
2210 const appConfig
= PDFViewerApplication
.appConfig
;
2212 const queryString
= document
.location
.search
.substring(1);
2213 const params
= (0, _ui_utils
.parseQueryString
)(queryString
);
2214 file
= "file" in params
? params
.file
: _app_options
.AppOptions
.get("defaultUrl");
2215 validateFileURL(file
);
2216 const fileInput
= document
.createElement("input");
2217 fileInput
.id
= appConfig
.openFileInputName
;
2218 fileInput
.className
= "fileInput";
2219 fileInput
.setAttribute("type", "file");
2220 fileInput
.oncontextmenu
= _ui_utils
.noContextMenuHandler
;
2221 document
.body
.appendChild(fileInput
);
2223 if (!window
.File
|| !window
.FileReader
|| !window
.FileList
|| !window
.Blob
) {
2224 appConfig
.toolbar
.openFile
.hidden
= true;
2225 appConfig
.secondaryToolbar
.openFileButton
.hidden
= true;
2227 fileInput
.value
= null;
2230 fileInput
.addEventListener("change", function (evt
) {
2231 const files
= evt
.target
.files
;
2233 if (!files
|| files
.length
=== 0) {
2237 PDFViewerApplication
.eventBus
.dispatch("fileinputchange", {
2239 fileInput
: evt
.target
2242 appConfig
.mainContainer
.addEventListener("dragover", function (evt
) {
2243 evt
.preventDefault();
2244 evt
.dataTransfer
.dropEffect
= "move";
2246 appConfig
.mainContainer
.addEventListener("drop", function (evt
) {
2247 evt
.preventDefault();
2248 const files
= evt
.dataTransfer
.files
;
2250 if (!files
|| files
.length
=== 0) {
2254 PDFViewerApplication
.eventBus
.dispatch("fileinputchange", {
2256 fileInput
: evt
.dataTransfer
2260 if (!PDFViewerApplication
.supportsDocumentFonts
) {
2261 _app_options
.AppOptions
.set("disableFontFace", true);
2263 PDFViewerApplication
.l10n
.get("web_fonts_disabled").then(msg
=> {
2268 if (!PDFViewerApplication
.supportsPrinting
) {
2269 appConfig
.toolbar
.print
.classList
.add("hidden");
2270 appConfig
.secondaryToolbar
.printButton
.classList
.add("hidden");
2273 if (!PDFViewerApplication
.supportsFullscreen
) {
2274 appConfig
.toolbar
.presentationModeButton
.classList
.add("hidden");
2275 appConfig
.secondaryToolbar
.presentationModeButton
.classList
.add("hidden");
2278 if (PDFViewerApplication
.supportsIntegratedFind
) {
2279 appConfig
.toolbar
.viewFind
.classList
.add("hidden");
2282 appConfig
.mainContainer
.addEventListener("transitionend", function (evt
) {
2283 if (evt
.target
=== this) {
2284 PDFViewerApplication
.eventBus
.dispatch("resize", {
2291 webViewerOpenFileViaURL(file
);
2293 PDFViewerApplication
.l10n
.get("loading_error").then(msg
=> {
2294 PDFViewerApplication
._documentError(msg
, reason
);
2299 function webViewerOpenFileViaURL(file
) {
2301 PDFViewerApplication
.open(file
);
2305 function webViewerResetPermissions() {
2308 } = PDFViewerApplication
;
2314 appConfig
.viewerContainer
.classList
.remove(ENABLE_PERMISSIONS_CLASS
);
2317 function webViewerPageRendered({
2322 if (pageNumber
=== PDFViewerApplication
.page
) {
2323 PDFViewerApplication
.toolbar
.updateLoadingIndicatorState(false);
2326 if (PDFViewerApplication
.pdfSidebar
.isThumbnailViewVisible
) {
2327 const pageView
= PDFViewerApplication
.pdfViewer
.getPageView(pageNumber
- 1);
2328 const thumbnailView
= PDFViewerApplication
.pdfThumbnailViewer
.getThumbnail(pageNumber
- 1);
2330 if (pageView
&& thumbnailView
) {
2331 thumbnailView
.setImage(pageView
);
2336 PDFViewerApplication
.l10n
.get("rendering_error").then(msg
=> {
2337 PDFViewerApplication
._otherError(msg
, error
);
2341 PDFViewerApplication
.externalServices
.reportTelemetry({
2345 PDFViewerApplication
.pdfDocument
.getStats().then(function (stats
) {
2346 PDFViewerApplication
.externalServices
.reportTelemetry({
2347 type
: "documentStats",
2353 function webViewerPageMode({
2360 view
= _ui_utils
.SidebarView
.THUMBS
;
2365 view
= _ui_utils
.SidebarView
.OUTLINE
;
2369 view
= _ui_utils
.SidebarView
.ATTACHMENTS
;
2373 view
= _ui_utils
.SidebarView
.LAYERS
;
2377 view
= _ui_utils
.SidebarView
.NONE
;
2381 console
.error('Invalid "pagemode" hash parameter: ' + mode
);
2385 PDFViewerApplication
.pdfSidebar
.switchView(view
, true);
2388 function webViewerNamedAction(evt
) {
2389 switch (evt
.action
) {
2391 PDFViewerApplication
.appConfig
.toolbar
.pageNumber
.select();
2395 if (!PDFViewerApplication
.supportsIntegratedFind
) {
2396 PDFViewerApplication
.findBar
.toggle();
2402 PDFViewerApplication
.triggerPrinting();
2411 function webViewerPresentationModeChanged(evt
) {
2412 PDFViewerApplication
.pdfViewer
.presentationModeState
= evt
.state
;
2415 function webViewerSidebarViewChanged(evt
) {
2416 PDFViewerApplication
.pdfRenderingQueue
.isThumbnailViewEnabled
= PDFViewerApplication
.pdfSidebar
.isThumbnailViewVisible
;
2417 const store
= PDFViewerApplication
.store
;
2419 if (store
&& PDFViewerApplication
.isInitialViewSet
) {
2420 store
.set("sidebarView", evt
.view
).catch(function () {});
2424 function webViewerUpdateViewarea(evt
) {
2425 const location
= evt
.location
,
2426 store
= PDFViewerApplication
.store
;
2428 if (store
&& PDFViewerApplication
.isInitialViewSet
) {
2430 page
: location
.pageNumber
,
2431 zoom
: location
.scale
,
2432 scrollLeft
: location
.left
,
2433 scrollTop
: location
.top
,
2434 rotation
: location
.rotation
2435 }).catch(function () {});
2438 const href
= PDFViewerApplication
.pdfLinkService
.getAnchorUrl(location
.pdfOpenParams
);
2439 PDFViewerApplication
.appConfig
.toolbar
.viewBookmark
.href
= href
;
2440 PDFViewerApplication
.appConfig
.secondaryToolbar
.viewBookmarkButton
.href
= href
;
2441 const currentPage
= PDFViewerApplication
.pdfViewer
.getPageView(PDFViewerApplication
.page
- 1);
2442 const loading
= currentPage
?.renderingState
!== _pdf_rendering_queue
.RenderingStates
.FINISHED
;
2443 PDFViewerApplication
.toolbar
.updateLoadingIndicatorState(loading
);
2446 function webViewerScrollModeChanged(evt
) {
2447 const store
= PDFViewerApplication
.store
;
2449 if (store
&& PDFViewerApplication
.isInitialViewSet
) {
2450 store
.set("scrollMode", evt
.mode
).catch(function () {});
2454 function webViewerSpreadModeChanged(evt
) {
2455 const store
= PDFViewerApplication
.store
;
2457 if (store
&& PDFViewerApplication
.isInitialViewSet
) {
2458 store
.set("spreadMode", evt
.mode
).catch(function () {});
2462 function webViewerResize() {
2466 } = PDFViewerApplication
;
2472 const currentScaleValue
= pdfViewer
.currentScaleValue
;
2474 if (currentScaleValue
=== "auto" || currentScaleValue
=== "page-fit" || currentScaleValue
=== "page-width") {
2475 pdfViewer
.currentScaleValue
= currentScaleValue
;
2481 function webViewerHashchange(evt
) {
2482 const hash
= evt
.hash
;
2488 if (!PDFViewerApplication
.isInitialViewSet
) {
2489 PDFViewerApplication
.initialBookmark
= hash
;
2490 } else if (!PDFViewerApplication
.pdfHistory
.popStateInProgress
) {
2491 PDFViewerApplication
.pdfLinkService
.setHash(hash
);
2495 let webViewerFileInputChange
, webViewerOpenFile
;
2497 webViewerFileInputChange = function (evt
) {
2498 if (PDFViewerApplication
.pdfViewer
?.isInPresentationMode
) {
2502 const file
= evt
.fileInput
.files
[0];
2504 if (!_viewer_compatibility
.viewerCompatibilityParams
.disableCreateObjectURL
) {
2505 let url
= URL
.createObjectURL(file
);
2510 originalUrl
: file
.name
2514 PDFViewerApplication
.open(url
);
2516 PDFViewerApplication
.setTitleUsingUrl(file
.name
);
2517 const fileReader
= new FileReader();
2519 fileReader
.onload
= function webViewerChangeFileReaderOnload(event
) {
2520 const buffer
= event
.target
.result
;
2521 PDFViewerApplication
.open(new Uint8Array(buffer
));
2524 fileReader
.readAsArrayBuffer(file
);
2527 const appConfig
= PDFViewerApplication
.appConfig
;
2528 appConfig
.toolbar
.viewBookmark
.hidden
= true;
2529 appConfig
.secondaryToolbar
.viewBookmarkButton
.hidden
= true;
2530 appConfig
.toolbar
.download
.hidden
= true;
2531 appConfig
.secondaryToolbar
.downloadButton
.hidden
= true;
2534 webViewerOpenFile = function (evt
) {
2535 const openFileInputName
= PDFViewerApplication
.appConfig
.openFileInputName
;
2536 document
.getElementById(openFileInputName
).click();
2540 function webViewerPresentationMode() {
2541 PDFViewerApplication
.requestPresentationMode();
2544 function webViewerPrint() {
2545 PDFViewerApplication
.triggerPrinting();
2548 function webViewerDownload() {
2549 PDFViewerApplication
.downloadOrSave({
2550 sourceEventType
: "download"
2554 function webViewerSave() {
2555 PDFViewerApplication
.downloadOrSave({
2556 sourceEventType
: "save"
2560 function webViewerFirstPage() {
2561 if (PDFViewerApplication
.pdfDocument
) {
2562 PDFViewerApplication
.page
= 1;
2566 function webViewerLastPage() {
2567 if (PDFViewerApplication
.pdfDocument
) {
2568 PDFViewerApplication
.page
= PDFViewerApplication
.pagesCount
;
2572 function webViewerNextPage() {
2573 PDFViewerApplication
.pdfViewer
.nextPage();
2576 function webViewerPreviousPage() {
2577 PDFViewerApplication
.pdfViewer
.previousPage();
2580 function webViewerZoomIn() {
2581 PDFViewerApplication
.zoomIn();
2584 function webViewerZoomOut() {
2585 PDFViewerApplication
.zoomOut();
2588 function webViewerZoomReset() {
2589 PDFViewerApplication
.zoomReset();
2592 function webViewerPageNumberChanged(evt
) {
2593 const pdfViewer
= PDFViewerApplication
.pdfViewer
;
2595 if (evt
.value
!== "") {
2596 PDFViewerApplication
.pdfLinkService
.goToPage(evt
.value
);
2599 if (evt
.value
!== pdfViewer
.currentPageNumber
.toString() && evt
.value
!== pdfViewer
.currentPageLabel
) {
2600 PDFViewerApplication
.toolbar
.setPageNumber(pdfViewer
.currentPageNumber
, pdfViewer
.currentPageLabel
);
2604 function webViewerScaleChanged(evt
) {
2605 PDFViewerApplication
.pdfViewer
.currentScaleValue
= evt
.value
;
2608 function webViewerRotateCw() {
2609 PDFViewerApplication
.rotatePages(90);
2612 function webViewerRotateCcw() {
2613 PDFViewerApplication
.rotatePages(-90);
2616 function webViewerOptionalContentConfig(evt
) {
2617 PDFViewerApplication
.pdfViewer
.optionalContentConfigPromise
= evt
.promise
;
2620 function webViewerSwitchScrollMode(evt
) {
2621 PDFViewerApplication
.pdfViewer
.scrollMode
= evt
.mode
;
2624 function webViewerSwitchSpreadMode(evt
) {
2625 PDFViewerApplication
.pdfViewer
.spreadMode
= evt
.mode
;
2628 function webViewerDocumentProperties() {
2629 PDFViewerApplication
.pdfDocumentProperties
.open();
2632 function webViewerFind(evt
) {
2633 PDFViewerApplication
.findController
.executeCommand("find" + evt
.type
, {
2635 phraseSearch
: evt
.phraseSearch
,
2636 caseSensitive
: evt
.caseSensitive
,
2637 entireWord
: evt
.entireWord
,
2638 highlightAll
: evt
.highlightAll
,
2639 findPrevious
: evt
.findPrevious
2643 function webViewerFindFromUrlHash(evt
) {
2644 PDFViewerApplication
.findController
.executeCommand("find", {
2646 phraseSearch
: evt
.phraseSearch
,
2647 caseSensitive
: false,
2654 function webViewerUpdateFindMatchesCount({
2657 if (PDFViewerApplication
.supportsIntegratedFind
) {
2658 PDFViewerApplication
.externalServices
.updateFindMatchesCount(matchesCount
);
2660 PDFViewerApplication
.findBar
.updateResultsCount(matchesCount
);
2664 function webViewerUpdateFindControlState({
2670 if (PDFViewerApplication
.supportsIntegratedFind
) {
2671 PDFViewerApplication
.externalServices
.updateFindControlState({
2673 findPrevious
: previous
,
2678 PDFViewerApplication
.findBar
.updateUIState(state
, previous
, matchesCount
);
2682 function webViewerScaleChanging(evt
) {
2683 PDFViewerApplication
.toolbar
.setPageScale(evt
.presetValue
, evt
.scale
);
2684 PDFViewerApplication
.pdfViewer
.update();
2687 function webViewerRotationChanging(evt
) {
2688 PDFViewerApplication
.pdfThumbnailViewer
.pagesRotation
= evt
.pagesRotation
;
2689 PDFViewerApplication
.forceRendering();
2690 PDFViewerApplication
.pdfViewer
.currentPageNumber
= evt
.pageNumber
;
2693 function webViewerPageChanging({
2697 PDFViewerApplication
.toolbar
.setPageNumber(pageNumber
, pageLabel
);
2698 PDFViewerApplication
.secondaryToolbar
.setPageNumber(pageNumber
);
2700 if (PDFViewerApplication
.pdfSidebar
.isThumbnailViewVisible
) {
2701 PDFViewerApplication
.pdfThumbnailViewer
.scrollThumbnailIntoView(pageNumber
);
2705 function webViewerVisibilityChange(evt
) {
2706 if (document
.visibilityState
=== "visible") {
2707 setZoomDisabledTimeout();
2711 let zoomDisabledTimeout
= null;
2713 function setZoomDisabledTimeout() {
2714 if (zoomDisabledTimeout
) {
2715 clearTimeout(zoomDisabledTimeout
);
2718 zoomDisabledTimeout
= setTimeout(function () {
2719 zoomDisabledTimeout
= null;
2720 }, WHEEL_ZOOM_DISABLED_TIMEOUT
);
2723 function webViewerWheel(evt
) {
2726 supportedMouseWheelZoomModifierKeys
2727 } = PDFViewerApplication
;
2729 if (pdfViewer
.isInPresentationMode
) {
2733 if (evt
.ctrlKey
&& supportedMouseWheelZoomModifierKeys
.ctrlKey
|| evt
.metaKey
&& supportedMouseWheelZoomModifierKeys
.metaKey
) {
2734 evt
.preventDefault();
2736 if (zoomDisabledTimeout
|| document
.visibilityState
=== "hidden") {
2740 const previousScale
= pdfViewer
.currentScale
;
2741 const delta
= (0, _ui_utils
.normalizeWheelEventDirection
)(evt
);
2744 if (evt
.deltaMode
=== WheelEvent
.DOM_DELTA_LINE
|| evt
.deltaMode
=== WheelEvent
.DOM_DELTA_PAGE
) {
2745 if (Math
.abs(delta
) >= 1) {
2746 ticks
= Math
.sign(delta
);
2748 ticks
= PDFViewerApplication
.accumulateWheelTicks(delta
);
2751 const PIXELS_PER_LINE_SCALE
= 30;
2752 ticks
= PDFViewerApplication
.accumulateWheelTicks(delta
/ PIXELS_PER_LINE_SCALE
);
2756 PDFViewerApplication
.zoomOut(-ticks
);
2757 } else if (ticks
> 0) {
2758 PDFViewerApplication
.zoomIn(ticks
);
2761 const currentScale
= pdfViewer
.currentScale
;
2763 if (previousScale
!== currentScale
) {
2764 const scaleCorrectionFactor
= currentScale
/ previousScale
- 1;
2765 const rect
= pdfViewer
.container
.getBoundingClientRect();
2766 const dx
= evt
.clientX
- rect
.left
;
2767 const dy
= evt
.clientY
- rect
.top
;
2768 pdfViewer
.container
.scrollLeft
+= dx
* scaleCorrectionFactor
;
2769 pdfViewer
.container
.scrollTop
+= dy
* scaleCorrectionFactor
;
2772 setZoomDisabledTimeout();
2776 function webViewerTouchStart(evt
) {
2777 if (evt
.touches
.length
> 1) {
2778 evt
.preventDefault();
2782 function webViewerClick(evt
) {
2783 if (!PDFViewerApplication
.secondaryToolbar
.isOpen
) {
2787 const appConfig
= PDFViewerApplication
.appConfig
;
2789 if (PDFViewerApplication
.pdfViewer
.containsElement(evt
.target
) || appConfig
.toolbar
.container
.contains(evt
.target
) && evt
.target
!== appConfig
.secondaryToolbar
.toggleButton
) {
2790 PDFViewerApplication
.secondaryToolbar
.close();
2794 function webViewerKeyDown(evt
) {
2795 if (PDFViewerApplication
.overlayManager
.active
) {
2799 let handled
= false,
2800 ensureViewerFocused
= false;
2801 const cmd
= (evt
.ctrlKey
? 1 : 0) | (evt
.altKey
? 2 : 0) | (evt
.shiftKey
? 4 : 0) | (evt
.metaKey
? 8 : 0);
2802 const pdfViewer
= PDFViewerApplication
.pdfViewer
;
2803 const isViewerInPresentationMode
= pdfViewer
?.isInPresentationMode
;
2805 if (cmd
=== 1 || cmd
=== 8 || cmd
=== 5 || cmd
=== 12) {
2806 switch (evt
.keyCode
) {
2808 if (!PDFViewerApplication
.supportsIntegratedFind
&& !evt
.shiftKey
) {
2809 PDFViewerApplication
.findBar
.open();
2816 if (!PDFViewerApplication
.supportsIntegratedFind
) {
2817 const findState
= PDFViewerApplication
.findController
.state
;
2820 PDFViewerApplication
.findController
.executeCommand("findagain", {
2821 query
: findState
.query
,
2822 phraseSearch
: findState
.phraseSearch
,
2823 caseSensitive
: findState
.caseSensitive
,
2824 entireWord
: findState
.entireWord
,
2825 highlightAll
: findState
.highlightAll
,
2826 findPrevious
: cmd
=== 5 || cmd
=== 12
2839 if (!isViewerInPresentationMode
) {
2840 PDFViewerApplication
.zoomIn();
2849 if (!isViewerInPresentationMode
) {
2850 PDFViewerApplication
.zoomOut();
2858 if (!isViewerInPresentationMode
) {
2859 setTimeout(function () {
2860 PDFViewerApplication
.zoomReset();
2868 if (isViewerInPresentationMode
|| PDFViewerApplication
.page
> 1) {
2869 PDFViewerApplication
.page
= 1;
2871 ensureViewerFocused
= true;
2877 if (isViewerInPresentationMode
|| PDFViewerApplication
.page
< PDFViewerApplication
.pagesCount
) {
2878 PDFViewerApplication
.page
= PDFViewerApplication
.pagesCount
;
2880 ensureViewerFocused
= true;
2889 } = PDFViewerApplication
;
2891 if (cmd
=== 1 || cmd
=== 8) {
2892 switch (evt
.keyCode
) {
2894 eventBus
.dispatch("download", {
2902 eventBus
.dispatch("openfile", {
2911 if (cmd
=== 3 || cmd
=== 10) {
2912 switch (evt
.keyCode
) {
2914 PDFViewerApplication
.requestPresentationMode();
2919 PDFViewerApplication
.appConfig
.toolbar
.pageNumber
.select();
2926 if (ensureViewerFocused
&& !isViewerInPresentationMode
) {
2930 evt
.preventDefault();
2934 const curElement
= (0, _ui_utils
.getActiveOrFocusedElement
)();
2935 const curElementTagName
= curElement
?.tagName
.toUpperCase();
2937 if (curElementTagName
=== "INPUT" || curElementTagName
=== "TEXTAREA" || curElementTagName
=== "SELECT" || curElement
?.isContentEditable
) {
2938 if (evt
.keyCode
!== 27) {
2945 turnOnlyIfPageFit
= false;
2947 switch (evt
.keyCode
) {
2950 if (pdfViewer
.isVerticalScrollbarEnabled
) {
2951 turnOnlyIfPageFit
= true;
2958 if (!isViewerInPresentationMode
) {
2959 turnOnlyIfPageFit
= true;
2966 if (pdfViewer
.isHorizontalScrollbarEnabled
) {
2967 turnOnlyIfPageFit
= true;
2976 if (PDFViewerApplication
.secondaryToolbar
.isOpen
) {
2977 PDFViewerApplication
.secondaryToolbar
.close();
2981 if (!PDFViewerApplication
.supportsIntegratedFind
&& PDFViewerApplication
.findBar
.opened
) {
2982 PDFViewerApplication
.findBar
.close();
2990 if (pdfViewer
.isVerticalScrollbarEnabled
) {
2991 turnOnlyIfPageFit
= true;
2999 if (!isViewerInPresentationMode
) {
3000 turnOnlyIfPageFit
= true;
3007 if (pdfViewer
.isHorizontalScrollbarEnabled
) {
3008 turnOnlyIfPageFit
= true;
3017 if (isViewerInPresentationMode
|| PDFViewerApplication
.page
> 1) {
3018 PDFViewerApplication
.page
= 1;
3020 ensureViewerFocused
= true;
3026 if (isViewerInPresentationMode
|| PDFViewerApplication
.page
< PDFViewerApplication
.pagesCount
) {
3027 PDFViewerApplication
.page
= PDFViewerApplication
.pagesCount
;
3029 ensureViewerFocused
= true;
3035 PDFViewerApplication
.pdfCursorTools
.switchTool(_pdf_cursor_tools
.CursorTool
.SELECT
);
3039 PDFViewerApplication
.pdfCursorTools
.switchTool(_pdf_cursor_tools
.CursorTool
.HAND
);
3043 PDFViewerApplication
.rotatePages(90);
3047 PDFViewerApplication
.pdfSidebar
.toggle();
3051 if (turnPage
!== 0 && (!turnOnlyIfPageFit
|| pdfViewer
.currentScaleValue
=== "page-fit")) {
3053 pdfViewer
.nextPage();
3055 pdfViewer
.previousPage();
3063 switch (evt
.keyCode
) {
3066 if (!isViewerInPresentationMode
&& pdfViewer
.currentScaleValue
!== "page-fit") {
3070 if (PDFViewerApplication
.page
> 1) {
3071 PDFViewerApplication
.page
--;
3078 PDFViewerApplication
.rotatePages(-90);
3083 if (!handled
&& !isViewerInPresentationMode
) {
3084 if (evt
.keyCode
>= 33 && evt
.keyCode
<= 40 || evt
.keyCode
=== 32 && curElementTagName
!== "BUTTON") {
3085 ensureViewerFocused
= true;
3089 if (ensureViewerFocused
&& !pdfViewer
.containsElement(curElement
)) {
3094 evt
.preventDefault();
3098 function beforeUnload(evt
) {
3099 evt
.preventDefault();
3100 evt
.returnValue
= "";
3104 const PDFPrintServiceFactory
= {
3106 supportsPrinting
: false,
3108 createPrintService() {
3109 throw new Error("Not implemented: createPrintService");
3114 exports
.PDFPrintServiceFactory
= PDFPrintServiceFactory
;
3118 /***/ ((__unused_webpack_module
, exports
) => {
3122 Object
.defineProperty(exports
, "__esModule", ({
3125 exports
.apiPageLayoutToSpreadMode
= apiPageLayoutToSpreadMode
;
3126 exports
.apiPageModeToSidebarView
= apiPageModeToSidebarView
;
3127 exports
.approximateFraction
= approximateFraction
;
3128 exports
.backtrackBeforeAllVisibleElements
= backtrackBeforeAllVisibleElements
;
3129 exports
.binarySearchFirstItem
= binarySearchFirstItem
;
3130 exports
.getActiveOrFocusedElement
= getActiveOrFocusedElement
;
3131 exports
.getOutputScale
= getOutputScale
;
3132 exports
.getPageSizeInches
= getPageSizeInches
;
3133 exports
.getVisibleElements
= getVisibleElements
;
3134 exports
.isPortraitOrientation
= isPortraitOrientation
;
3135 exports
.isValidRotation
= isValidRotation
;
3136 exports
.isValidScrollMode
= isValidScrollMode
;
3137 exports
.isValidSpreadMode
= isValidSpreadMode
;
3138 exports
.moveToEndOfArray
= moveToEndOfArray
;
3139 exports
.noContextMenuHandler
= noContextMenuHandler
;
3140 exports
.normalizeWheelEventDelta
= normalizeWheelEventDelta
;
3141 exports
.normalizeWheelEventDirection
= normalizeWheelEventDirection
;
3142 exports
.parseQueryString
= parseQueryString
;
3143 exports
.roundToDivide
= roundToDivide
;
3144 exports
.scrollIntoView
= scrollIntoView
;
3145 exports
.waitOnEventOrTimeout
= waitOnEventOrTimeout
;
3146 exports
.watchScroll
= watchScroll
;
3147 exports
.WaitOnType
= exports
.VERTICAL_PADDING
= exports
.UNKNOWN_SCALE
= exports
.TextLayerMode
= exports
.SpreadMode
= exports
.SidebarView
= exports
.ScrollMode
= exports
.SCROLLBAR_PADDING
= exports
.RendererType
= exports
.ProgressBar
= exports
.PresentationModeState
= exports
.MIN_SCALE
= exports
.MAX_SCALE
= exports
.MAX_AUTO_SCALE
= exports
.EventBus
= exports
.DEFAULT_SCALE_VALUE
= exports
.DEFAULT_SCALE
= exports
.CSS_UNITS
= exports
.AutoPrintRegExp
= exports
.animationStarted
= void 0;
3148 const CSS_UNITS
= 96.0 / 72.0;
3149 exports
.CSS_UNITS
= CSS_UNITS
;
3150 const DEFAULT_SCALE_VALUE
= "auto";
3151 exports
.DEFAULT_SCALE_VALUE
= DEFAULT_SCALE_VALUE
;
3152 const DEFAULT_SCALE
= 1.0;
3153 exports
.DEFAULT_SCALE
= DEFAULT_SCALE
;
3154 const MIN_SCALE
= 0.1;
3155 exports
.MIN_SCALE
= MIN_SCALE
;
3156 const MAX_SCALE
= 10.0;
3157 exports
.MAX_SCALE
= MAX_SCALE
;
3158 const UNKNOWN_SCALE
= 0;
3159 exports
.UNKNOWN_SCALE
= UNKNOWN_SCALE
;
3160 const MAX_AUTO_SCALE
= 1.25;
3161 exports
.MAX_AUTO_SCALE
= MAX_AUTO_SCALE
;
3162 const SCROLLBAR_PADDING
= 40;
3163 exports
.SCROLLBAR_PADDING
= SCROLLBAR_PADDING
;
3164 const VERTICAL_PADDING
= 5;
3165 exports
.VERTICAL_PADDING
= VERTICAL_PADDING
;
3166 const LOADINGBAR_END_OFFSET_VAR
= "--loadingBar-end-offset";
3167 const PresentationModeState
= {
3173 exports
.PresentationModeState
= PresentationModeState
;
3174 const SidebarView
= {
3182 exports
.SidebarView
= SidebarView
;
3183 const RendererType
= {
3187 exports
.RendererType
= RendererType
;
3188 const TextLayerMode
= {
3193 exports
.TextLayerMode
= TextLayerMode
;
3194 const ScrollMode
= {
3200 exports
.ScrollMode
= ScrollMode
;
3201 const SpreadMode
= {
3207 exports
.SpreadMode
= SpreadMode
;
3208 const AutoPrintRegExp
= /\bprint\s*\(/;
3209 exports
.AutoPrintRegExp
= AutoPrintRegExp
;
3211 function getOutputScale(ctx
) {
3212 const devicePixelRatio
= window
.devicePixelRatio
|| 1;
3213 const backingStoreRatio
= ctx
.webkitBackingStorePixelRatio
|| ctx
.mozBackingStorePixelRatio
|| ctx
.backingStorePixelRatio
|| 1;
3214 const pixelRatio
= devicePixelRatio
/ backingStoreRatio
;
3218 scaled
: pixelRatio
!== 1
3222 function scrollIntoView(element
, spot
, scrollMatches
= false) {
3223 let parent
= element
.offsetParent
;
3226 console
.error("offsetParent is not set -- cannot scroll");
3230 let offsetY
= element
.offsetTop
+ element
.clientTop
;
3231 let offsetX
= element
.offsetLeft
+ element
.clientLeft
;
3233 while (parent
.clientHeight
=== parent
.scrollHeight
&& parent
.clientWidth
=== parent
.scrollWidth
|| scrollMatches
&& (parent
.classList
.contains("markedContent") || getComputedStyle(parent
).overflow
=== "hidden")) {
3234 offsetY
+= parent
.offsetTop
;
3235 offsetX
+= parent
.offsetLeft
;
3236 parent
= parent
.offsetParent
;
3244 if (spot
.top
!== undefined) {
3245 offsetY
+= spot
.top
;
3248 if (spot
.left
!== undefined) {
3249 offsetX
+= spot
.left
;
3250 parent
.scrollLeft
= offsetX
;
3254 parent
.scrollTop
= offsetY
;
3257 function watchScroll(viewAreaElement
, callback
) {
3258 const debounceScroll = function (evt
) {
3263 rAF
= window
.requestAnimationFrame(function viewAreaElementScrolled() {
3265 const currentX
= viewAreaElement
.scrollLeft
;
3266 const lastX
= state
.lastX
;
3268 if (currentX
!== lastX
) {
3269 state
.right
= currentX
> lastX
;
3272 state
.lastX
= currentX
;
3273 const currentY
= viewAreaElement
.scrollTop
;
3274 const lastY
= state
.lastY
;
3276 if (currentY
!== lastY
) {
3277 state
.down
= currentY
> lastY
;
3280 state
.lastY
= currentY
;
3288 lastX
: viewAreaElement
.scrollLeft
,
3289 lastY
: viewAreaElement
.scrollTop
,
3290 _eventHandler
: debounceScroll
3293 viewAreaElement
.addEventListener("scroll", debounceScroll
, true);
3297 function parseQueryString(query
) {
3298 const parts
= query
.split("&");
3299 const params
= Object
.create(null);
3301 for (let i
= 0, ii
= parts
.length
; i
< ii
; ++i
) {
3302 const param
= parts
[i
].split("=");
3303 const key
= param
[0].toLowerCase();
3304 const value
= param
.length
> 1 ? param
[1] : null;
3305 params
[decodeURIComponent(key
)] = decodeURIComponent(value
);
3311 function binarySearchFirstItem(items
, condition
) {
3313 let maxIndex
= items
.length
- 1;
3315 if (maxIndex
< 0 || !condition(items
[maxIndex
])) {
3316 return items
.length
;
3319 if (condition(items
[minIndex
])) {
3323 while (minIndex
< maxIndex
) {
3324 const currentIndex
= minIndex
+ maxIndex
>> 1;
3325 const currentItem
= items
[currentIndex
];
3327 if (condition(currentItem
)) {
3328 maxIndex
= currentIndex
;
3330 minIndex
= currentIndex
+ 1;
3337 function approximateFraction(x
) {
3338 if (Math
.floor(x
) === x
) {
3347 } else if (Math
.floor(xinv
) === xinv
) {
3351 const x_
= x
> 1 ? xinv
: x
;
3376 if (x_
- a
/ b
< c
/ d
- x_
) {
3377 result
= x_
=== x
? [a
, b
] : [b
, a
];
3379 result
= x_
=== x
? [c
, d
] : [d
, c
];
3385 function roundToDivide(x
, div
) {
3387 return r
=== 0 ? x
: Math
.round(x
- r
+ div
);
3390 function getPageSizeInches({
3395 const [x1
, y1
, x2
, y2
] = view
;
3396 const changeOrientation
= rotate
% 180 !== 0;
3397 const width
= (x2
- x1
) / 72 * userUnit
;
3398 const height
= (y2
- y1
) / 72 * userUnit
;
3400 width
: changeOrientation
? height
: width
,
3401 height
: changeOrientation
? width
: height
3405 function backtrackBeforeAllVisibleElements(index
, views
, top
) {
3410 let elt
= views
[index
].div
;
3411 let pageTop
= elt
.offsetTop
+ elt
.clientTop
;
3413 if (pageTop
>= top
) {
3414 elt
= views
[index
- 1].div
;
3415 pageTop
= elt
.offsetTop
+ elt
.clientTop
;
3418 for (let i
= index
- 2; i
>= 0; --i
) {
3421 if (elt
.offsetTop
+ elt
.clientTop
+ elt
.clientHeight
<= pageTop
) {
3431 function getVisibleElements({
3434 sortByVisibility
= false,
3438 const top
= scrollEl
.scrollTop
,
3439 bottom
= top
+ scrollEl
.clientHeight
;
3440 const left
= scrollEl
.scrollLeft
,
3441 right
= left
+ scrollEl
.clientWidth
;
3443 function isElementBottomAfterViewTop(view
) {
3444 const element
= view
.div
;
3445 const elementBottom
= element
.offsetTop
+ element
.clientTop
+ element
.clientHeight
;
3446 return elementBottom
> top
;
3449 function isElementNextAfterViewHorizontally(view
) {
3450 const element
= view
.div
;
3451 const elementLeft
= element
.offsetLeft
+ element
.clientLeft
;
3452 const elementRight
= elementLeft
+ element
.clientWidth
;
3453 return rtl
? elementLeft
< right
: elementRight
> left
;
3457 numViews
= views
.length
;
3458 let firstVisibleElementInd
= binarySearchFirstItem(views
, horizontal
? isElementNextAfterViewHorizontally
: isElementBottomAfterViewTop
);
3460 if (firstVisibleElementInd
> 0 && firstVisibleElementInd
< numViews
&& !horizontal
) {
3461 firstVisibleElementInd
= backtrackBeforeAllVisibleElements(firstVisibleElementInd
, views
, top
);
3464 let lastEdge
= horizontal
? right
: -1;
3466 for (let i
= firstVisibleElementInd
; i
< numViews
; i
++) {
3467 const view
= views
[i
],
3469 const currentWidth
= element
.offsetLeft
+ element
.clientLeft
;
3470 const currentHeight
= element
.offsetTop
+ element
.clientTop
;
3471 const viewWidth
= element
.clientWidth
,
3472 viewHeight
= element
.clientHeight
;
3473 const viewRight
= currentWidth
+ viewWidth
;
3474 const viewBottom
= currentHeight
+ viewHeight
;
3476 if (lastEdge
=== -1) {
3477 if (viewBottom
>= bottom
) {
3478 lastEdge
= viewBottom
;
3480 } else if ((horizontal
? currentWidth
: currentHeight
) > lastEdge
) {
3484 if (viewBottom
<= top
|| currentHeight
>= bottom
|| viewRight
<= left
|| currentWidth
>= right
) {
3488 const hiddenHeight
= Math
.max(0, top
- currentHeight
) + Math
.max(0, viewBottom
- bottom
);
3489 const hiddenWidth
= Math
.max(0, left
- currentWidth
) + Math
.max(0, viewRight
- right
);
3490 const fractionHeight
= (viewHeight
- hiddenHeight
) / viewHeight
,
3491 fractionWidth
= (viewWidth
- hiddenWidth
) / viewWidth
;
3492 const percent
= fractionHeight
* fractionWidth
* 100 | 0;
3499 widthPercent
: fractionWidth
* 100 | 0
3503 const first
= visible
[0],
3504 last
= visible
[visible
.length
- 1];
3506 if (sortByVisibility
) {
3507 visible
.sort(function (a
, b
) {
3508 const pc
= a
.percent
- b
.percent
;
3510 if (Math
.abs(pc
) > 0.001) {
3525 function noContextMenuHandler(evt
) {
3526 evt
.preventDefault();
3529 function normalizeWheelEventDirection(evt
) {
3530 let delta
= Math
.hypot(evt
.deltaX
, evt
.deltaY
);
3531 const angle
= Math
.atan2(evt
.deltaY
, evt
.deltaX
);
3533 if (-0.25 * Math
.PI
< angle
&& angle
< 0.75 * Math
.PI
) {
3540 function normalizeWheelEventDelta(evt
) {
3541 let delta
= normalizeWheelEventDirection(evt
);
3542 const MOUSE_DOM_DELTA_PIXEL_MODE
= 0;
3543 const MOUSE_DOM_DELTA_LINE_MODE
= 1;
3544 const MOUSE_PIXELS_PER_LINE
= 30;
3545 const MOUSE_LINES_PER_PAGE
= 30;
3547 if (evt
.deltaMode
=== MOUSE_DOM_DELTA_PIXEL_MODE
) {
3548 delta
/= MOUSE_PIXELS_PER_LINE
* MOUSE_LINES_PER_PAGE
;
3549 } else if (evt
.deltaMode
=== MOUSE_DOM_DELTA_LINE_MODE
) {
3550 delta
/= MOUSE_LINES_PER_PAGE
;
3556 function isValidRotation(angle
) {
3557 return Number
.isInteger(angle
) && angle
% 90 === 0;
3560 function isValidScrollMode(mode
) {
3561 return Number
.isInteger(mode
) && Object
.values(ScrollMode
).includes(mode
) && mode
!== ScrollMode
.UNKNOWN
;
3564 function isValidSpreadMode(mode
) {
3565 return Number
.isInteger(mode
) && Object
.values(SpreadMode
).includes(mode
) && mode
!== SpreadMode
.UNKNOWN
;
3568 function isPortraitOrientation(size
) {
3569 return size
.width
<= size
.height
;
3572 const WaitOnType
= {
3576 exports
.WaitOnType
= WaitOnType
;
3578 function waitOnEventOrTimeout({
3583 return new Promise(function (resolve
, reject
) {
3584 if (typeof target
!== "object" || !(name
&& typeof name
=== "string") || !(Number
.isInteger(delay
) && delay
>= 0)) {
3585 throw new Error("waitOnEventOrTimeout - invalid parameters.");
3588 function handler(type
) {
3589 if (target
instanceof EventBus
) {
3590 target
._off(name
, eventHandler
);
3592 target
.removeEventListener(name
, eventHandler
);
3596 clearTimeout(timeout
);
3602 const eventHandler
= handler
.bind(null, WaitOnType
.EVENT
);
3604 if (target
instanceof EventBus
) {
3605 target
._on(name
, eventHandler
);
3607 target
.addEventListener(name
, eventHandler
);
3610 const timeoutHandler
= handler
.bind(null, WaitOnType
.TIMEOUT
);
3611 const timeout
= setTimeout(timeoutHandler
, delay
);
3615 const animationStarted
= new Promise(function (resolve
) {
3616 window
.requestAnimationFrame(resolve
);
3618 exports
.animationStarted
= animationStarted
;
3620 function dispatchDOMEvent(eventName
, args
= null) {
3621 throw new Error("Not implemented: dispatchDOMEvent");
3625 constructor(options
) {
3626 this._listeners
= Object
.create(null);
3629 on(eventName
, listener
, options
= null) {
3630 this._on(eventName
, listener
, {
3636 off(eventName
, listener
, options
= null) {
3637 this._off(eventName
, listener
, {
3643 dispatch(eventName
) {
3644 const eventListeners
= this._listeners
[eventName
];
3646 if (!eventListeners
|| eventListeners
.length
=== 0) {
3650 const args
= Array
.prototype.slice
.call(arguments
, 1);
3651 let externalListeners
;
3657 } of eventListeners
.slice(0)) {
3659 this._off(eventName
, listener
);
3663 (externalListeners
|| (externalListeners
= [])).push(listener
);
3667 listener
.apply(null, args
);
3670 if (externalListeners
) {
3671 for (const listener
of externalListeners
) {
3672 listener
.apply(null, args
);
3675 externalListeners
= null;
3679 _on(eventName
, listener
, options
= null) {
3680 var _this
$_listeners
;
3682 const eventListeners
= (_this
$_listeners
= this._listeners
)[eventName
] || (_this
$_listeners
[eventName
] = []);
3683 eventListeners
.push({
3685 external
: options
?.external
=== true,
3686 once
: options
?.once
=== true
3690 _off(eventName
, listener
, options
= null) {
3691 const eventListeners
= this._listeners
[eventName
];
3693 if (!eventListeners
) {
3697 for (let i
= 0, ii
= eventListeners
.length
; i
< ii
; i
++) {
3698 if (eventListeners
[i
].listener
=== listener
) {
3699 eventListeners
.splice(i
, 1);
3707 exports
.EventBus
= EventBus
;
3709 function clamp(v
, min
, max
) {
3710 return Math
.min(Math
.max(v
, min
), max
);
3719 this.visible
= true;
3720 this.div
= document
.querySelector(id
+ " .progress");
3721 this.bar
= this.div
.parentNode
;
3722 this.height
= height
|| 100;
3723 this.width
= width
|| 100;
3724 this.units
= units
|| "%";
3725 this.div
.style
.height
= this.height
+ this.units
;
3730 if (this._indeterminate
) {
3731 this.div
.classList
.add("indeterminate");
3732 this.div
.style
.width
= this.width
+ this.units
;
3736 this.div
.classList
.remove("indeterminate");
3737 const progressSize
= this.width
* this._percent
/ 100;
3738 this.div
.style
.width
= progressSize
+ this.units
;
3742 return this._percent
;
3746 this._indeterminate
= isNaN(val
);
3747 this._percent
= clamp(val
, 0, 100);
3757 const container
= viewer
.parentNode
;
3758 const scrollbarWidth
= container
.offsetWidth
- viewer
.offsetWidth
;
3760 if (scrollbarWidth
> 0) {
3761 const doc
= document
.documentElement
;
3762 doc
.style
.setProperty(LOADINGBAR_END_OFFSET_VAR
, `${scrollbarWidth}px`);
3767 if (!this.visible
) {
3771 this.visible
= false;
3772 this.bar
.classList
.add("hidden");
3780 this.visible
= true;
3781 this.bar
.classList
.remove("hidden");
3786 exports
.ProgressBar
= ProgressBar
;
3788 function moveToEndOfArray(arr
, condition
) {
3793 for (let read
= 0; read
< len
; ++read
) {
3794 if (condition(arr
[read
])) {
3795 moved
.push(arr
[read
]);
3797 arr
[write
] = arr
[read
];
3802 for (let read
= 0; write
< len
; ++read
, ++write
) {
3803 arr
[write
] = moved
[read
];
3807 function getActiveOrFocusedElement() {
3808 let curRoot
= document
;
3809 let curActiveOrFocused
= curRoot
.activeElement
|| curRoot
.querySelector(":focus");
3811 while (curActiveOrFocused
?.shadowRoot
) {
3812 curRoot
= curActiveOrFocused
.shadowRoot
;
3813 curActiveOrFocused
= curRoot
.activeElement
|| curRoot
.querySelector(":focus");
3816 return curActiveOrFocused
;
3819 function apiPageLayoutToSpreadMode(layout
) {
3823 return SpreadMode
.NONE
;
3825 case "TwoColumnLeft":
3827 return SpreadMode
.ODD
;
3829 case "TwoColumnRight":
3830 case "TwoPageRight":
3831 return SpreadMode
.EVEN
;
3834 return SpreadMode
.NONE
;
3837 function apiPageModeToSidebarView(mode
) {
3840 return SidebarView
.NONE
;
3843 return SidebarView
.THUMBS
;
3846 return SidebarView
.OUTLINE
;
3848 case "UseAttachments":
3849 return SidebarView
.ATTACHMENTS
;
3852 return SidebarView
.LAYERS
;
3855 return SidebarView
.NONE
;
3860 /***/ ((module
) => {
3866 if (typeof window
!== "undefined" && window
["pdfjs-dist/build/pdf"]) {
3867 pdfjsLib
= window
["pdfjs-dist/build/pdf"];
3869 pdfjsLib
= require("../build/pdf.js");
3872 module
.exports
= pdfjsLib
;
3876 /***/ ((__unused_webpack_module
, exports
, __webpack_require__
) => {
3880 Object
.defineProperty(exports
, "__esModule", ({
3883 exports
.PDFCursorTools
= exports
.CursorTool
= void 0;
3885 var _grab_to_pan
= __webpack_require__(7);
3887 var _ui_utils
= __webpack_require__(4);
3889 const CursorTool
= {
3894 exports
.CursorTool
= CursorTool
;
3896 class PDFCursorTools
{
3900 cursorToolOnLoad
= CursorTool
.SELECT
3902 this.container
= container
;
3903 this.eventBus
= eventBus
;
3904 this.active
= CursorTool
.SELECT
;
3905 this.activeBeforePresentationMode
= null;
3906 this.handTool
= new _grab_to_pan
.GrabToPan({
3907 element
: this.container
3910 this._addEventListeners();
3912 Promise
.resolve().then(() => {
3913 this.switchTool(cursorToolOnLoad
);
3922 if (this.activeBeforePresentationMode
!== null) {
3926 if (tool
=== this.active
) {
3930 const disableActiveTool
= () => {
3931 switch (this.active
) {
3932 case CursorTool
.SELECT
:
3935 case CursorTool
.HAND
:
3936 this.handTool
.deactivate();
3939 case CursorTool
.ZOOM
:
3944 case CursorTool
.SELECT
:
3945 disableActiveTool();
3948 case CursorTool
.HAND
:
3949 disableActiveTool();
3950 this.handTool
.activate();
3953 case CursorTool
.ZOOM
:
3955 console
.error(`switchTool: "${tool}" is an unsupported value.`);
3961 this._dispatchEvent();
3965 this.eventBus
.dispatch("cursortoolchanged", {
3971 _addEventListeners() {
3972 this.eventBus
._on("switchcursortool", evt
=> {
3973 this.switchTool(evt
.tool
);
3976 this.eventBus
._on("presentationmodechanged", evt
=> {
3977 switch (evt
.state
) {
3978 case _ui_utils
.PresentationModeState
.FULLSCREEN
:
3980 const previouslyActive
= this.active
;
3981 this.switchTool(CursorTool
.SELECT
);
3982 this.activeBeforePresentationMode
= previouslyActive
;
3986 case _ui_utils
.PresentationModeState
.NORMAL
:
3988 const previouslyActive
= this.activeBeforePresentationMode
;
3989 this.activeBeforePresentationMode
= null;
3990 this.switchTool(previouslyActive
);
3999 exports
.PDFCursorTools
= PDFCursorTools
;
4003 /***/ ((__unused_webpack_module
, exports
) => {
4007 Object
.defineProperty(exports
, "__esModule", ({
4010 exports
.GrabToPan
= GrabToPan
;
4012 function GrabToPan(options
) {
4013 this.element
= options
.element
;
4014 this.document
= options
.element
.ownerDocument
;
4016 if (typeof options
.ignoreTarget
=== "function") {
4017 this.ignoreTarget
= options
.ignoreTarget
;
4020 this.onActiveChanged
= options
.onActiveChanged
;
4021 this.activate
= this.activate
.bind(this);
4022 this.deactivate
= this.deactivate
.bind(this);
4023 this.toggle
= this.toggle
.bind(this);
4024 this._onmousedown
= this._onmousedown
.bind(this);
4025 this._onmousemove
= this._onmousemove
.bind(this);
4026 this._endPan
= this._endPan
.bind(this);
4027 const overlay
= this.overlay
= document
.createElement("div");
4028 overlay
.className
= "grab-to-pan-grabbing";
4031 GrabToPan
.prototype = {
4032 CSS_CLASS_GRAB
: "grab-to-pan-grab",
4033 activate
: function GrabToPan_activate() {
4036 this.element
.addEventListener("mousedown", this._onmousedown
, true);
4037 this.element
.classList
.add(this.CSS_CLASS_GRAB
);
4039 if (this.onActiveChanged
) {
4040 this.onActiveChanged(true);
4044 deactivate
: function GrabToPan_deactivate() {
4046 this.active
= false;
4047 this.element
.removeEventListener("mousedown", this._onmousedown
, true);
4051 this.element
.classList
.remove(this.CSS_CLASS_GRAB
);
4053 if (this.onActiveChanged
) {
4054 this.onActiveChanged(false);
4058 toggle
: function GrabToPan_toggle() {
4065 ignoreTarget
: function GrabToPan_ignoreTarget(node
) {
4066 return node
.matches("a[href], a[href] *, input, textarea, button, button *, select, option");
4068 _onmousedown
: function GrabToPan__onmousedown(event
) {
4069 if (event
.button
!== 0 || this.ignoreTarget(event
.target
)) {
4073 if (event
.originalTarget
) {
4075 event
.originalTarget
.tagName
;
4081 this.scrollLeftStart
= this.element
.scrollLeft
;
4082 this.scrollTopStart
= this.element
.scrollTop
;
4083 this.clientXStart
= event
.clientX
;
4084 this.clientYStart
= event
.clientY
;
4085 this.document
.addEventListener("mousemove", this._onmousemove
, true);
4086 this.document
.addEventListener("mouseup", this._endPan
, true);
4087 this.element
.addEventListener("scroll", this._endPan
, true);
4088 event
.preventDefault();
4089 event
.stopPropagation();
4090 const focusedElement
= document
.activeElement
;
4092 if (focusedElement
&& !focusedElement
.contains(event
.target
)) {
4093 focusedElement
.blur();
4096 _onmousemove
: function GrabToPan__onmousemove(event
) {
4097 this.element
.removeEventListener("scroll", this._endPan
, true);
4099 if (isLeftMouseReleased(event
)) {
4105 const xDiff
= event
.clientX
- this.clientXStart
;
4106 const yDiff
= event
.clientY
- this.clientYStart
;
4107 const scrollTop
= this.scrollTopStart
- yDiff
;
4108 const scrollLeft
= this.scrollLeftStart
- xDiff
;
4110 if (this.element
.scrollTo
) {
4111 this.element
.scrollTo({
4117 this.element
.scrollTop
= scrollTop
;
4118 this.element
.scrollLeft
= scrollLeft
;
4121 if (!this.overlay
.parentNode
) {
4122 document
.body
.appendChild(this.overlay
);
4125 _endPan
: function GrabToPan__endPan() {
4126 this.element
.removeEventListener("scroll", this._endPan
, true);
4127 this.document
.removeEventListener("mousemove", this._onmousemove
, true);
4128 this.document
.removeEventListener("mouseup", this._endPan
, true);
4129 this.overlay
.remove();
4133 function isLeftMouseReleased(event
) {
4134 if ("buttons" in event
) {
4135 return !(event
.buttons
& 1);
4138 const chrome
= window
.chrome
;
4139 const isChrome15OrOpera15plus
= chrome
&& (chrome
.webstore
|| chrome
.app
);
4140 const isSafari6plus
= /Apple/.test(navigator
.vendor
) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator
.userAgent
);
4142 if (isChrome15OrOpera15plus
|| isSafari6plus
) {
4143 return event
.which
=== 0;
4151 /***/ ((__unused_webpack_module
, exports
, __webpack_require__
) => {
4155 Object
.defineProperty(exports
, "__esModule", ({
4158 exports
.RenderingStates
= exports
.PDFRenderingQueue
= void 0;
4160 var _pdfjsLib
= __webpack_require__(5);
4162 const CLEANUP_TIMEOUT
= 30000;
4163 const RenderingStates
= {
4169 exports
.RenderingStates
= RenderingStates
;
4171 class PDFRenderingQueue
{
4173 this.pdfViewer
= null;
4174 this.pdfThumbnailViewer
= null;
4176 this.highestPriorityPage
= null;
4177 this.idleTimeout
= null;
4178 this.printing
= false;
4179 this.isThumbnailViewEnabled
= false;
4182 setViewer(pdfViewer
) {
4183 this.pdfViewer
= pdfViewer
;
4186 setThumbnailViewer(pdfThumbnailViewer
) {
4187 this.pdfThumbnailViewer
= pdfThumbnailViewer
;
4190 isHighestPriority(view
) {
4191 return this.highestPriorityPage
=== view
.renderingId
;
4194 renderHighestPriority(currentlyVisiblePages
) {
4195 if (this.idleTimeout
) {
4196 clearTimeout(this.idleTimeout
);
4197 this.idleTimeout
= null;
4200 if (this.pdfViewer
.forceRendering(currentlyVisiblePages
)) {
4204 if (this.pdfThumbnailViewer
&& this.isThumbnailViewEnabled
) {
4205 if (this.pdfThumbnailViewer
.forceRendering()) {
4210 if (this.printing
) {
4215 this.idleTimeout
= setTimeout(this.onIdle
.bind(this), CLEANUP_TIMEOUT
);
4219 getHighestPriority(visible
, views
, scrolledDown
) {
4220 const visibleViews
= visible
.views
;
4221 const numVisible
= visibleViews
.length
;
4223 if (numVisible
=== 0) {
4227 for (let i
= 0; i
< numVisible
; ++i
) {
4228 const view
= visibleViews
[i
].view
;
4230 if (!this.isViewFinished(view
)) {
4236 const nextPageIndex
= visible
.last
.id
;
4238 if (views
[nextPageIndex
] && !this.isViewFinished(views
[nextPageIndex
])) {
4239 return views
[nextPageIndex
];
4242 const previousPageIndex
= visible
.first
.id
- 2;
4244 if (views
[previousPageIndex
] && !this.isViewFinished(views
[previousPageIndex
])) {
4245 return views
[previousPageIndex
];
4252 isViewFinished(view
) {
4253 return view
.renderingState
=== RenderingStates
.FINISHED
;
4257 switch (view
.renderingState
) {
4258 case RenderingStates
.FINISHED
:
4261 case RenderingStates
.PAUSED
:
4262 this.highestPriorityPage
= view
.renderingId
;
4266 case RenderingStates
.RUNNING
:
4267 this.highestPriorityPage
= view
.renderingId
;
4270 case RenderingStates
.INITIAL
:
4271 this.highestPriorityPage
= view
.renderingId
;
4272 view
.draw().finally(() => {
4273 this.renderHighestPriority();
4274 }).catch(reason
=> {
4275 if (reason
instanceof _pdfjsLib
.RenderingCancelledException
) {
4279 console
.error(`renderView: "${reason}"`);
4289 exports
.PDFRenderingQueue
= PDFRenderingQueue
;
4293 /***/ ((__unused_webpack_module
, exports
) => {
4297 Object
.defineProperty(exports
, "__esModule", ({
4300 exports
.OverlayManager
= void 0;
4302 class OverlayManager
{
4304 this._overlays
= {};
4305 this._active
= null;
4306 this._keyDownBound
= this._keyDown
.bind(this);
4310 return this._active
;
4313 async
register(name
, element
, callerCloseMethod
= null, canForceClose
= false) {
4316 if (!name
|| !element
|| !(container
= element
.parentNode
)) {
4317 throw new Error("Not enough parameters.");
4318 } else if (this._overlays
[name
]) {
4319 throw new Error("The overlay is already registered.");
4322 this._overlays
[name
] = {
4330 async
unregister(name
) {
4331 if (!this._overlays
[name
]) {
4332 throw new Error("The overlay does not exist.");
4333 } else if (this._active
=== name
) {
4334 throw new Error("The overlay cannot be removed while it is active.");
4337 delete this._overlays
[name
];
4341 if (!this._overlays
[name
]) {
4342 throw new Error("The overlay does not exist.");
4343 } else if (this._active
) {
4344 if (this._overlays
[name
].canForceClose
) {
4345 this._closeThroughCaller();
4346 } else if (this._active
=== name
) {
4347 throw new Error("The overlay is already active.");
4349 throw new Error("Another overlay is currently active.");
4353 this._active
= name
;
4355 this._overlays
[this._active
].element
.classList
.remove("hidden");
4357 this._overlays
[this._active
].container
.classList
.remove("hidden");
4359 window
.addEventListener("keydown", this._keyDownBound
);
4363 if (!this._overlays
[name
]) {
4364 throw new Error("The overlay does not exist.");
4365 } else if (!this._active
) {
4366 throw new Error("The overlay is currently not active.");
4367 } else if (this._active
!== name
) {
4368 throw new Error("Another overlay is currently active.");
4371 this._overlays
[this._active
].container
.classList
.add("hidden");
4373 this._overlays
[this._active
].element
.classList
.add("hidden");
4375 this._active
= null;
4376 window
.removeEventListener("keydown", this._keyDownBound
);
4380 if (this._active
&& evt
.keyCode
=== 27) {
4381 this._closeThroughCaller();
4383 evt
.preventDefault();
4387 _closeThroughCaller() {
4388 if (this._overlays
[this._active
].callerCloseMethod
) {
4389 this._overlays
[this._active
].callerCloseMethod();
4393 this.close(this._active
);
4399 exports
.OverlayManager
= OverlayManager
;
4403 /***/ ((__unused_webpack_module
, exports
, __webpack_require__
) => {
4407 Object
.defineProperty(exports
, "__esModule", ({
4410 exports
.PasswordPrompt
= void 0;
4412 var _pdfjsLib
= __webpack_require__(5);
4414 class PasswordPrompt
{
4415 constructor(options
, overlayManager
, l10n
, isViewerEmbedded
= false) {
4416 this.overlayName
= options
.overlayName
;
4417 this.container
= options
.container
;
4418 this.label
= options
.label
;
4419 this.input
= options
.input
;
4420 this.submitButton
= options
.submitButton
;
4421 this.cancelButton
= options
.cancelButton
;
4422 this.overlayManager
= overlayManager
;
4424 this._isViewerEmbedded
= isViewerEmbedded
;
4425 this.updateCallback
= null;
4427 this.submitButton
.addEventListener("click", this.verify
.bind(this));
4428 this.cancelButton
.addEventListener("click", this.close
.bind(this));
4429 this.input
.addEventListener("keydown", e
=> {
4430 if (e
.keyCode
=== 13) {
4434 this.overlayManager
.register(this.overlayName
, this.container
, this.close
.bind(this), true);
4438 await
this.overlayManager
.open(this.overlayName
);
4439 const passwordIncorrect
= this.reason
=== _pdfjsLib
.PasswordResponses
.INCORRECT_PASSWORD
;
4441 if (!this._isViewerEmbedded
|| passwordIncorrect
) {
4445 this.label
.textContent
= await
this.l10n
.get(`password_${passwordIncorrect ? "invalid" : "label"}`);
4449 this.overlayManager
.close(this.overlayName
).then(() => {
4450 this.input
.value
= "";
4455 const password
= this.input
.value
;
4457 if (password
?.length
> 0) {
4459 this.updateCallback(password
);
4463 setUpdateCallback(updateCallback
, reason
) {
4464 this.updateCallback
= updateCallback
;
4465 this.reason
= reason
;
4470 exports
.PasswordPrompt
= PasswordPrompt
;
4474 /***/ ((__unused_webpack_module
, exports
, __webpack_require__
) => {
4478 Object
.defineProperty(exports
, "__esModule", ({
4481 exports
.PDFAttachmentViewer
= void 0;
4483 var _pdfjsLib
= __webpack_require__(5);
4485 var _base_tree_viewer
= __webpack_require__(12);
4487 class PDFAttachmentViewer
extends _base_tree_viewer
.BaseTreeViewer
{
4488 constructor(options
) {
4490 this.downloadManager
= options
.downloadManager
;
4492 this.eventBus
._on("fileattachmentannotation", this._appendAttachment
.bind(this));
4495 reset(keepRenderedCapability
= false) {
4497 this._attachments
= null;
4499 if (!keepRenderedCapability
) {
4500 this._renderedCapability
= (0, _pdfjsLib
.createPromiseCapability
)();
4503 if (this._pendingDispatchEvent
) {
4504 clearTimeout(this._pendingDispatchEvent
);
4507 this._pendingDispatchEvent
= null;
4510 _dispatchEvent(attachmentsCount
) {
4511 this._renderedCapability
.resolve();
4513 if (this._pendingDispatchEvent
) {
4514 clearTimeout(this._pendingDispatchEvent
);
4515 this._pendingDispatchEvent
= null;
4518 if (attachmentsCount
=== 0) {
4519 this._pendingDispatchEvent
= setTimeout(() => {
4520 this.eventBus
.dispatch("attachmentsloaded", {
4524 this._pendingDispatchEvent
= null;
4529 this.eventBus
.dispatch("attachmentsloaded", {
4535 _bindLink(element
, {
4539 element
.onclick
= () => {
4540 this.downloadManager
.openOrDownloadData(element
, content
, filename
);
4547 keepRenderedCapability
= false
4549 if (this._attachments
) {
4550 this.reset(keepRenderedCapability
);
4553 this._attachments
= attachments
|| null;
4556 this._dispatchEvent(0);
4561 const names
= Object
.keys(attachments
).sort(function (a
, b
) {
4562 return a
.toLowerCase().localeCompare(b
.toLowerCase());
4564 const fragment
= document
.createDocumentFragment();
4565 let attachmentsCount
= 0;
4567 for (const name
of names
) {
4568 const item
= attachments
[name
];
4569 const content
= item
.content
,
4570 filename
= (0, _pdfjsLib
.getFilenameFromUrl
)(item
.filename
);
4571 const div
= document
.createElement("div");
4572 div
.className
= "treeItem";
4573 const element
= document
.createElement("a");
4575 this._bindLink(element
, {
4580 element
.textContent
= this._normalizeTextContent(filename
);
4581 div
.appendChild(element
);
4582 fragment
.appendChild(div
);
4586 this._finishRendering(fragment
, attachmentsCount
);
4594 const renderedPromise
= this._renderedCapability
.promise
;
4595 renderedPromise
.then(() => {
4596 if (renderedPromise
!== this._renderedCapability
.promise
) {
4600 let attachments
= this._attachments
;
4603 attachments
= Object
.create(null);
4605 for (const name
in attachments
) {
4618 keepRenderedCapability
: true
4625 exports
.PDFAttachmentViewer
= PDFAttachmentViewer
;
4629 /***/ ((__unused_webpack_module
, exports
, __webpack_require__
) => {
4633 Object
.defineProperty(exports
, "__esModule", ({
4636 exports
.BaseTreeViewer
= void 0;
4638 var _pdfjsLib
= __webpack_require__(5);
4640 const TREEITEM_OFFSET_TOP
= -100;
4641 const TREEITEM_SELECTED_CLASS
= "selected";
4643 class BaseTreeViewer
{
4644 constructor(options
) {
4645 if (this.constructor === BaseTreeViewer
) {
4646 throw new Error("Cannot initialize BaseTreeViewer.");
4649 this.container
= options
.container
;
4650 this.eventBus
= options
.eventBus
;
4655 this._pdfDocument
= null;
4656 this._lastToggleIsShow
= true;
4657 this._currentTreeItem
= null;
4658 this.container
.textContent
= "";
4659 this.container
.classList
.remove("treeWithDeepNesting");
4662 _dispatchEvent(count
) {
4663 throw new Error("Not implemented: _dispatchEvent");
4666 _bindLink(element
, params
) {
4667 throw new Error("Not implemented: _bindLink");
4670 _normalizeTextContent(str
) {
4671 return (0, _pdfjsLib
.removeNullCharacters
)(str
) || "\u2013";
4674 _addToggleButton(div
, hidden
= false) {
4675 const toggler
= document
.createElement("div");
4676 toggler
.className
= "treeItemToggler";
4679 toggler
.classList
.add("treeItemsHidden");
4682 toggler
.onclick
= evt
=> {
4683 evt
.stopPropagation();
4684 toggler
.classList
.toggle("treeItemsHidden");
4687 const shouldShowAll
= !toggler
.classList
.contains("treeItemsHidden");
4689 this._toggleTreeItem(div
, shouldShowAll
);
4693 div
.insertBefore(toggler
, div
.firstChild
);
4696 _toggleTreeItem(root
, show
= false) {
4697 this._lastToggleIsShow
= show
;
4699 for (const toggler
of root
.querySelectorAll(".treeItemToggler")) {
4700 toggler
.classList
.toggle("treeItemsHidden", !show
);
4704 _toggleAllTreeItems() {
4705 this._toggleTreeItem(this.container
, !this._lastToggleIsShow
);
4708 _finishRendering(fragment
, count
, hasAnyNesting
= false) {
4709 if (hasAnyNesting
) {
4710 this.container
.classList
.add("treeWithDeepNesting");
4711 this._lastToggleIsShow
= !fragment
.querySelector(".treeItemsHidden");
4714 this.container
.appendChild(fragment
);
4716 this._dispatchEvent(count
);
4720 throw new Error("Not implemented: render");
4723 _updateCurrentTreeItem(treeItem
= null) {
4724 if (this._currentTreeItem
) {
4725 this._currentTreeItem
.classList
.remove(TREEITEM_SELECTED_CLASS
);
4727 this._currentTreeItem
= null;
4731 treeItem
.classList
.add(TREEITEM_SELECTED_CLASS
);
4732 this._currentTreeItem
= treeItem
;
4736 _scrollToCurrentTreeItem(treeItem
) {
4741 let currentNode
= treeItem
.parentNode
;
4743 while (currentNode
&& currentNode
!== this.container
) {
4744 if (currentNode
.classList
.contains("treeItem")) {
4745 const toggler
= currentNode
.firstElementChild
;
4746 toggler
?.classList
.remove("treeItemsHidden");
4749 currentNode
= currentNode
.parentNode
;
4752 this._updateCurrentTreeItem(treeItem
);
4754 this.container
.scrollTo(treeItem
.offsetLeft
, treeItem
.offsetTop
+ TREEITEM_OFFSET_TOP
);
4759 exports
.BaseTreeViewer
= BaseTreeViewer
;
4763 /***/ ((__unused_webpack_module
, exports
, __webpack_require__
) => {
4767 Object
.defineProperty(exports
, "__esModule", ({
4770 exports
.PDFDocumentProperties
= void 0;
4772 var _pdfjsLib
= __webpack_require__(5);
4774 var _ui_utils
= __webpack_require__(4);
4776 const DEFAULT_FIELD_CONTENT
= "-";
4777 const NON_METRIC_LOCALES
= ["en-us", "en-lr", "my"];
4778 const US_PAGE_NAMES
= {
4782 const METRIC_PAGE_NAMES
= {
4787 function getPageName(size
, isPortrait
, pageNames
) {
4788 const width
= isPortrait
? size
.width
: size
.height
;
4789 const height
= isPortrait
? size
.height
: size
.width
;
4790 return pageNames
[`${width}x${height}`];
4793 class PDFDocumentProperties
{
4799 }, overlayManager
, eventBus
, l10n
) {
4800 this.overlayName
= overlayName
;
4801 this.fields
= fields
;
4802 this.container
= container
;
4803 this.overlayManager
= overlayManager
;
4808 closeButton
.addEventListener("click", this.close
.bind(this));
4809 this.overlayManager
.register(this.overlayName
, this.container
, this.close
.bind(this));
4811 eventBus
._on("pagechanging", evt
=> {
4812 this._currentPageNumber
= evt
.pageNumber
;
4815 eventBus
._on("rotationchanging", evt
=> {
4816 this._pagesRotation
= evt
.pagesRotation
;
4819 this._isNonMetricLocale
= true;
4820 l10n
.getLanguage().then(locale
=> {
4821 this._isNonMetricLocale
= NON_METRIC_LOCALES
.includes(locale
);
4826 const freezeFieldData
= data
=> {
4827 Object
.defineProperty(this, "fieldData", {
4828 value
: Object
.freeze(data
),
4835 await Promise
.all([this.overlayManager
.open(this.overlayName
), this._dataAvailableCapability
.promise
]);
4836 const currentPageNumber
= this._currentPageNumber
;
4837 const pagesRotation
= this._pagesRotation
;
4839 if (this.fieldData
&& currentPageNumber
=== this.fieldData
._currentPageNumber
&& pagesRotation
=== this.fieldData
._pagesRotation
) {
4847 contentDispositionFilename
,
4849 } = await
this.pdfDocument
.getMetadata();
4850 const [fileName
, fileSize
, creationDate
, modificationDate
, pageSize
, isLinearized
] = await Promise
.all([contentDispositionFilename
|| (0, _pdfjsLib
.getPdfFilenameFromUrl
)(this.url
), this._parseFileSize(contentLength
), this._parseDate(info
.CreationDate
), this._parseDate(info
.ModDate
), this.pdfDocument
.getPage(currentPageNumber
).then(pdfPage
=> {
4851 return this._parsePageSize((0, _ui_utils
.getPageSizeInches
)(pdfPage
), pagesRotation
);
4852 }), this._parseLinearization(info
.IsLinearized
)]);
4857 author
: info
.Author
,
4858 subject
: info
.Subject
,
4859 keywords
: info
.Keywords
,
4862 creator
: info
.Creator
,
4863 producer
: info
.Producer
,
4864 version
: info
.PDFFormatVersion
,
4865 pageCount
: this.pdfDocument
.numPages
,
4867 linearized
: isLinearized
,
4868 _currentPageNumber
: currentPageNumber
,
4869 _pagesRotation
: pagesRotation
4876 } = await
this.pdfDocument
.getDownloadInfo();
4878 if (contentLength
=== length
) {
4882 const data
= Object
.assign(Object
.create(null), this.fieldData
);
4883 data
.fileSize
= await
this._parseFileSize(length
);
4884 freezeFieldData(data
);
4890 this.overlayManager
.close(this.overlayName
);
4893 setDocument(pdfDocument
, url
= null) {
4894 if (this.pdfDocument
) {
4897 this._updateUI(true);
4904 this.pdfDocument
= pdfDocument
;
4907 this._dataAvailableCapability
.resolve();
4911 this.pdfDocument
= null;
4913 delete this.fieldData
;
4914 this._dataAvailableCapability
= (0, _pdfjsLib
.createPromiseCapability
)();
4915 this._currentPageNumber
= 1;
4916 this._pagesRotation
= 0;
4919 _updateUI(reset
= false) {
4920 if (reset
|| !this.fieldData
) {
4921 for (const id
in this.fields
) {
4922 this.fields
[id
].textContent
= DEFAULT_FIELD_CONTENT
;
4928 if (this.overlayManager
.active
!== this.overlayName
) {
4932 for (const id
in this.fields
) {
4933 const content
= this.fieldData
[id
];
4934 this.fields
[id
].textContent
= content
|| content
=== 0 ? content
: DEFAULT_FIELD_CONTENT
;
4938 async
_parseFileSize(fileSize
= 0) {
4939 const kb
= fileSize
/ 1024,
4946 return this.l10n
.get(`document_properties_${mb >= 1 ? "mb" : "kb"}`, {
4947 size_mb
: mb
>= 1 && (+mb
.toPrecision(3)).toLocaleString(),
4948 size_kb
: mb
< 1 && (+kb
.toPrecision(3)).toLocaleString(),
4949 size_b
: fileSize
.toLocaleString()
4953 async
_parsePageSize(pageSizeInches
, pagesRotation
) {
4954 if (!pageSizeInches
) {
4958 if (pagesRotation
% 180 !== 0) {
4960 width
: pageSizeInches
.height
,
4961 height
: pageSizeInches
.width
4965 const isPortrait
= (0, _ui_utils
.isPortraitOrientation
)(pageSizeInches
);
4967 width
: Math
.round(pageSizeInches
.width
* 100) / 100,
4968 height
: Math
.round(pageSizeInches
.height
* 100) / 100
4970 let sizeMillimeters
= {
4971 width
: Math
.round(pageSizeInches
.width
* 25.4 * 10) / 10,
4972 height
: Math
.round(pageSizeInches
.height
* 25.4 * 10) / 10
4974 let rawName
= getPageName(sizeInches
, isPortrait
, US_PAGE_NAMES
) || getPageName(sizeMillimeters
, isPortrait
, METRIC_PAGE_NAMES
);
4976 if (!rawName
&& !(Number
.isInteger(sizeMillimeters
.width
) && Number
.isInteger(sizeMillimeters
.height
))) {
4977 const exactMillimeters
= {
4978 width
: pageSizeInches
.width
* 25.4,
4979 height
: pageSizeInches
.height
* 25.4
4981 const intMillimeters
= {
4982 width
: Math
.round(sizeMillimeters
.width
),
4983 height
: Math
.round(sizeMillimeters
.height
)
4986 if (Math
.abs(exactMillimeters
.width
- intMillimeters
.width
) < 0.1 && Math
.abs(exactMillimeters
.height
- intMillimeters
.height
) < 0.1) {
4987 rawName
= getPageName(intMillimeters
, isPortrait
, METRIC_PAGE_NAMES
);
4991 width
: Math
.round(intMillimeters
.width
/ 25.4 * 100) / 100,
4992 height
: Math
.round(intMillimeters
.height
/ 25.4 * 100) / 100
4994 sizeMillimeters
= intMillimeters
;
5002 }, unit
, name
, orientation
] = await Promise
.all([this._isNonMetricLocale
? sizeInches
: sizeMillimeters
, this.l10n
.get(`document_properties_page_size_unit_${this._isNonMetricLocale ? "inches" : "millimeters"}`), rawName
&& this.l10n
.get(`document_properties_page_size_name_${rawName.toLowerCase()}`), this.l10n
.get(`document_properties_page_size_orientation_${isPortrait ? "portrait" : "landscape"}`)]);
5003 return this.l10n
.get(`document_properties_page_size_dimension_${name ? "name_" : ""}string`, {
5004 width
: width
.toLocaleString(),
5005 height
: height
.toLocaleString(),
5012 async
_parseDate(inputDate
) {
5013 const dateObject
= _pdfjsLib
.PDFDateString
.toDateObject(inputDate
);
5019 return this.l10n
.get("document_properties_date_string", {
5020 date
: dateObject
.toLocaleDateString(),
5021 time
: dateObject
.toLocaleTimeString()
5025 _parseLinearization(isLinearized
) {
5026 return this.l10n
.get(`document_properties_linearized_${isLinearized ? "yes" : "no"}`);
5031 exports
.PDFDocumentProperties
= PDFDocumentProperties
;
5035 /***/ ((__unused_webpack_module
, exports
, __webpack_require__
) => {
5039 Object
.defineProperty(exports
, "__esModule", ({
5042 exports
.PDFFindBar
= void 0;
5044 var _pdf_find_controller
= __webpack_require__(15);
5046 const MATCHES_COUNT_LIMIT
= 1000;
5049 constructor(options
, eventBus
, l10n
) {
5050 this.opened
= false;
5051 this.bar
= options
.bar
;
5052 this.toggleButton
= options
.toggleButton
;
5053 this.findField
= options
.findField
;
5054 this.highlightAll
= options
.highlightAllCheckbox
;
5055 this.caseSensitive
= options
.caseSensitiveCheckbox
;
5056 this.entireWord
= options
.entireWordCheckbox
;
5057 this.findMsg
= options
.findMsg
;
5058 this.findResultsCount
= options
.findResultsCount
;
5059 this.findPreviousButton
= options
.findPreviousButton
;
5060 this.findNextButton
= options
.findNextButton
;
5061 this.eventBus
= eventBus
;
5063 this.toggleButton
.addEventListener("click", () => {
5066 this.findField
.addEventListener("input", () => {
5067 this.dispatchEvent("");
5069 this.bar
.addEventListener("keydown", e
=> {
5070 switch (e
.keyCode
) {
5072 if (e
.target
=== this.findField
) {
5073 this.dispatchEvent("again", e
.shiftKey
);
5083 this.findPreviousButton
.addEventListener("click", () => {
5084 this.dispatchEvent("again", true);
5086 this.findNextButton
.addEventListener("click", () => {
5087 this.dispatchEvent("again", false);
5089 this.highlightAll
.addEventListener("click", () => {
5090 this.dispatchEvent("highlightallchange");
5092 this.caseSensitive
.addEventListener("click", () => {
5093 this.dispatchEvent("casesensitivitychange");
5095 this.entireWord
.addEventListener("click", () => {
5096 this.dispatchEvent("entirewordchange");
5099 this.eventBus
._on("resize", this._adjustWidth
.bind(this));
5103 this.updateUIState();
5106 dispatchEvent(type
, findPrev
) {
5107 this.eventBus
.dispatch("find", {
5110 query
: this.findField
.value
,
5112 caseSensitive
: this.caseSensitive
.checked
,
5113 entireWord
: this.entireWord
.checked
,
5114 highlightAll
: this.highlightAll
.checked
,
5115 findPrevious
: findPrev
5119 updateUIState(state
, previous
, matchesCount
) {
5120 let findMsg
= Promise
.resolve("");
5124 case _pdf_find_controller
.FindState
.FOUND
:
5127 case _pdf_find_controller
.FindState
.PENDING
:
5131 case _pdf_find_controller
.FindState
.NOT_FOUND
:
5132 findMsg
= this.l10n
.get("find_not_found");
5133 status
= "notFound";
5136 case _pdf_find_controller
.FindState
.WRAPPED
:
5137 findMsg
= this.l10n
.get(`find_reached_${previous ? "top" : "bottom"}`);
5141 this.findField
.setAttribute("data-status", status
);
5142 findMsg
.then(msg
=> {
5143 this.findMsg
.textContent
= msg
;
5145 this._adjustWidth();
5147 this.updateResultsCount(matchesCount
);
5150 updateResultsCount({
5154 const limit
= MATCHES_COUNT_LIMIT
;
5155 let matchCountMsg
= Promise
.resolve("");
5158 if (total
> limit
) {
5159 let key
= "find_match_count_limit";
5160 matchCountMsg
= this.l10n
.get(key
, {
5164 let key
= "find_match_count";
5165 matchCountMsg
= this.l10n
.get(key
, {
5172 matchCountMsg
.then(msg
=> {
5173 this.findResultsCount
.textContent
= msg
;
5174 this.findResultsCount
.classList
.toggle("hidden", !total
);
5176 this._adjustWidth();
5183 this.toggleButton
.classList
.add("toggled");
5184 this.toggleButton
.setAttribute("aria-expanded", "true");
5185 this.bar
.classList
.remove("hidden");
5188 this.findField
.select();
5189 this.findField
.focus();
5191 this._adjustWidth();
5199 this.opened
= false;
5200 this.toggleButton
.classList
.remove("toggled");
5201 this.toggleButton
.setAttribute("aria-expanded", "false");
5202 this.bar
.classList
.add("hidden");
5203 this.eventBus
.dispatch("findbarclose", {
5221 this.bar
.classList
.remove("wrapContainers");
5222 const findbarHeight
= this.bar
.clientHeight
;
5223 const inputContainerHeight
= this.bar
.firstElementChild
.clientHeight
;
5225 if (findbarHeight
> inputContainerHeight
) {
5226 this.bar
.classList
.add("wrapContainers");
5232 exports
.PDFFindBar
= PDFFindBar
;
5236 /***/ ((__unused_webpack_module
, exports
, __webpack_require__
) => {
5240 Object
.defineProperty(exports
, "__esModule", ({
5243 exports
.PDFFindController
= exports
.FindState
= void 0;
5245 var _pdfjsLib
= __webpack_require__(5);
5247 var _pdf_find_utils
= __webpack_require__(16);
5249 var _ui_utils
= __webpack_require__(4);
5257 exports
.FindState
= FindState
;
5258 const FIND_TIMEOUT
= 250;
5259 const MATCH_SCROLL_OFFSET_TOP
= -50;
5260 const MATCH_SCROLL_OFFSET_LEFT
= -400;
5261 const CHARACTERS_TO_NORMALIZE
= {
5275 let normalizationRegex
= null;
5277 function normalize(text
) {
5278 if (!normalizationRegex
) {
5279 const replace
= Object
.keys(CHARACTERS_TO_NORMALIZE
).join("");
5280 normalizationRegex
= new RegExp(`[${replace}]`, "g");
5284 const normalizedText
= text
.replace(normalizationRegex
, function (ch
, index
) {
5285 const normalizedCh
= CHARACTERS_TO_NORMALIZE
[ch
],
5286 diff
= normalizedCh
.length
- ch
.length
;
5289 (diffs
|| (diffs
= [])).push([index
, diff
]);
5292 return normalizedCh
;
5294 return [normalizedText
, diffs
];
5297 function getOriginalIndex(matchIndex
, diffs
= null) {
5304 for (const [index
, diff
] of diffs
) {
5305 const currentIndex
= index
+ totalDiff
;
5307 if (currentIndex
>= matchIndex
) {
5311 if (currentIndex
+ diff
> matchIndex
) {
5312 totalDiff
+= matchIndex
- currentIndex
;
5319 return matchIndex
- totalDiff
;
5322 class PDFFindController
{
5327 this._linkService
= linkService
;
5328 this._eventBus
= eventBus
;
5332 eventBus
._on("findbarclose", this._onFindBarClose
.bind(this));
5335 get highlightMatches() {
5336 return this._highlightMatches
;
5340 return this._pageMatches
;
5343 get pageMatchesLength() {
5344 return this._pageMatchesLength
;
5348 return this._selected
;
5355 setDocument(pdfDocument
) {
5356 if (this._pdfDocument
) {
5364 this._pdfDocument
= pdfDocument
;
5366 this._firstPageCapability
.resolve();
5369 executeCommand(cmd
, state
) {
5374 const pdfDocument
= this._pdfDocument
;
5376 if (this._state
=== null || this._shouldDirtyMatch(cmd
, state
)) {
5377 this._dirtyMatch
= true;
5380 this._state
= state
;
5382 if (cmd
!== "findhighlightallchange") {
5383 this._updateUIState(FindState
.PENDING
);
5386 this._firstPageCapability
.promise
.then(() => {
5387 if (!this._pdfDocument
|| pdfDocument
&& this._pdfDocument
!== pdfDocument
) {
5391 this._extractText();
5393 const findbarClosed
= !this._highlightMatches
;
5394 const pendingTimeout
= !!this._findTimeout
;
5396 if (this._findTimeout
) {
5397 clearTimeout(this._findTimeout
);
5398 this._findTimeout
= null;
5401 if (cmd
=== "find") {
5402 this._findTimeout
= setTimeout(() => {
5405 this._findTimeout
= null;
5407 } else if (this._dirtyMatch
) {
5409 } else if (cmd
=== "findagain") {
5412 if (findbarClosed
&& this._state
.highlightAll
) {
5413 this._updateAllPages();
5415 } else if (cmd
=== "findhighlightallchange") {
5416 if (pendingTimeout
) {
5419 this._highlightMatches
= true;
5422 this._updateAllPages();
5429 scrollMatchIntoView({
5435 if (!this._scrollMatches
|| !element
) {
5437 } else if (matchIndex
=== -1 || matchIndex
!== this._selected
.matchIdx
) {
5439 } else if (pageIndex
=== -1 || pageIndex
!== this._selected
.pageIdx
) {
5443 this._scrollMatches
= false;
5445 top
: MATCH_SCROLL_OFFSET_TOP
,
5446 left
: selectedLeft
+ MATCH_SCROLL_OFFSET_LEFT
5448 (0, _ui_utils
.scrollIntoView
)(element
, spot
, true);
5452 this._highlightMatches
= false;
5453 this._scrollMatches
= false;
5454 this._pdfDocument
= null;
5455 this._pageMatches
= [];
5456 this._pageMatchesLength
= [];
5467 this._extractTextPromises
= [];
5468 this._pageContents
= [];
5469 this._pageDiffs
= [];
5470 this._matchesCountTotal
= 0;
5471 this._pagesToSearch
= null;
5472 this._pendingFindMatches
= new Set();
5473 this._resumePageIdx
= null;
5474 this._dirtyMatch
= false;
5475 clearTimeout(this._findTimeout
);
5476 this._findTimeout
= null;
5477 this._firstPageCapability
= (0, _pdfjsLib
.createPromiseCapability
)();
5481 if (this._state
.query
!== this._rawQuery
) {
5482 this._rawQuery
= this._state
.query
;
5483 [this._normalizedQuery
] = normalize(this._state
.query
);
5486 return this._normalizedQuery
;
5489 _shouldDirtyMatch(cmd
, state
) {
5490 if (state
.query
!== this._state
.query
) {
5496 const pageNumber
= this._selected
.pageIdx
+ 1;
5497 const linkService
= this._linkService
;
5499 if (pageNumber
>= 1 && pageNumber
<= linkService
.pagesCount
&& pageNumber
!== linkService
.page
&& !linkService
.isPageVisible(pageNumber
)) {
5505 case "findhighlightallchange":
5512 _prepareMatches(matchesWithLength
, matches
, matchesLength
) {
5513 function isSubTerm(currentIndex
) {
5514 const currentElem
= matchesWithLength
[currentIndex
];
5515 const nextElem
= matchesWithLength
[currentIndex
+ 1];
5517 if (currentIndex
< matchesWithLength
.length
- 1 && currentElem
.match
=== nextElem
.match
) {
5518 currentElem
.skipped
= true;
5522 for (let i
= currentIndex
- 1; i
>= 0; i
--) {
5523 const prevElem
= matchesWithLength
[i
];
5525 if (prevElem
.skipped
) {
5529 if (prevElem
.match
+ prevElem
.matchLength
< currentElem
.match
) {
5533 if (prevElem
.match
+ prevElem
.matchLength
>= currentElem
.match
+ currentElem
.matchLength
) {
5534 currentElem
.skipped
= true;
5542 matchesWithLength
.sort(function (a
, b
) {
5543 return a
.match
=== b
.match
? a
.matchLength
- b
.matchLength
: a
.match
- b
.match
;
5546 for (let i
= 0, len
= matchesWithLength
.length
; i
< len
; i
++) {
5551 matches
.push(matchesWithLength
[i
].match
);
5552 matchesLength
.push(matchesWithLength
[i
].matchLength
);
5556 _isEntireWord(content
, startIdx
, length
) {
5558 const first
= content
.charCodeAt(startIdx
);
5559 const limit
= content
.charCodeAt(startIdx
- 1);
5561 if ((0, _pdf_find_utils
.getCharacterType
)(first
) === (0, _pdf_find_utils
.getCharacterType
)(limit
)) {
5566 const endIdx
= startIdx
+ length
- 1;
5568 if (endIdx
< content
.length
- 1) {
5569 const last
= content
.charCodeAt(endIdx
);
5570 const limit
= content
.charCodeAt(endIdx
+ 1);
5572 if ((0, _pdf_find_utils
.getCharacterType
)(last
) === (0, _pdf_find_utils
.getCharacterType
)(limit
)) {
5580 _calculatePhraseMatch(query
, pageIndex
, pageContent
, pageDiffs
, entireWord
) {
5583 const queryLen
= query
.length
;
5584 let matchIdx
= -queryLen
;
5587 matchIdx
= pageContent
.indexOf(query
, matchIdx
+ queryLen
);
5589 if (matchIdx
=== -1) {
5593 if (entireWord
&& !this._isEntireWord(pageContent
, matchIdx
, queryLen
)) {
5597 const originalMatchIdx
= getOriginalIndex(matchIdx
, pageDiffs
),
5598 matchEnd
= matchIdx
+ queryLen
- 1,
5599 originalQueryLen
= getOriginalIndex(matchEnd
, pageDiffs
) - originalMatchIdx
+ 1;
5600 matches
.push(originalMatchIdx
);
5601 matchesLength
.push(originalQueryLen
);
5604 this._pageMatches
[pageIndex
] = matches
;
5605 this._pageMatchesLength
[pageIndex
] = matchesLength
;
5608 _calculateWordMatch(query
, pageIndex
, pageContent
, pageDiffs
, entireWord
) {
5609 const matchesWithLength
= [];
5610 const queryArray
= query
.match(/\S+/g);
5612 for (let i
= 0, len
= queryArray
.length
; i
< len
; i
++) {
5613 const subquery
= queryArray
[i
];
5614 const subqueryLen
= subquery
.length
;
5615 let matchIdx
= -subqueryLen
;
5618 matchIdx
= pageContent
.indexOf(subquery
, matchIdx
+ subqueryLen
);
5620 if (matchIdx
=== -1) {
5624 if (entireWord
&& !this._isEntireWord(pageContent
, matchIdx
, subqueryLen
)) {
5628 const originalMatchIdx
= getOriginalIndex(matchIdx
, pageDiffs
),
5629 matchEnd
= matchIdx
+ subqueryLen
- 1,
5630 originalQueryLen
= getOriginalIndex(matchEnd
, pageDiffs
) - originalMatchIdx
+ 1;
5631 matchesWithLength
.push({
5632 match
: originalMatchIdx
,
5633 matchLength
: originalQueryLen
,
5639 this._pageMatchesLength
[pageIndex
] = [];
5640 this._pageMatches
[pageIndex
] = [];
5642 this._prepareMatches(matchesWithLength
, this._pageMatches
[pageIndex
], this._pageMatchesLength
[pageIndex
]);
5645 _calculateMatch(pageIndex
) {
5646 let pageContent
= this._pageContents
[pageIndex
];
5647 const pageDiffs
= this._pageDiffs
[pageIndex
];
5648 let query
= this._query
;
5655 if (query
.length
=== 0) {
5659 if (!caseSensitive
) {
5660 pageContent
= pageContent
.toLowerCase();
5661 query
= query
.toLowerCase();
5665 this._calculatePhraseMatch(query
, pageIndex
, pageContent
, pageDiffs
, entireWord
);
5667 this._calculateWordMatch(query
, pageIndex
, pageContent
, pageDiffs
, entireWord
);
5670 if (this._state
.highlightAll
) {
5671 this._updatePage(pageIndex
);
5674 if (this._resumePageIdx
=== pageIndex
) {
5675 this._resumePageIdx
= null;
5677 this._nextPageMatch();
5680 const pageMatchesCount
= this._pageMatches
[pageIndex
].length
;
5682 if (pageMatchesCount
> 0) {
5683 this._matchesCountTotal
+= pageMatchesCount
;
5685 this._updateUIResultsCount();
5690 if (this._extractTextPromises
.length
> 0) {
5694 let promise
= Promise
.resolve();
5696 for (let i
= 0, ii
= this._linkService
.pagesCount
; i
< ii
; i
++) {
5697 const extractTextCapability
= (0, _pdfjsLib
.createPromiseCapability
)();
5698 this._extractTextPromises
[i
] = extractTextCapability
.promise
;
5699 promise
= promise
.then(() => {
5700 return this._pdfDocument
.getPage(i
+ 1).then(pdfPage
=> {
5701 return pdfPage
.getTextContent({
5702 normalizeWhitespace
: true
5704 }).then(textContent
=> {
5705 const textItems
= textContent
.items
;
5708 for (let j
= 0, jj
= textItems
.length
; j
< jj
; j
++) {
5709 strBuf
.push(textItems
[j
].str
);
5712 [this._pageContents
[i
], this._pageDiffs
[i
]] = normalize(strBuf
.join(""));
5713 extractTextCapability
.resolve(i
);
5715 console
.error(`Unable to get text content for page ${i + 1}`, reason
);
5716 this._pageContents
[i
] = "";
5717 this._pageDiffs
[i
] = null;
5718 extractTextCapability
.resolve(i
);
5724 _updatePage(index
) {
5725 if (this._scrollMatches
&& this._selected
.pageIdx
=== index
) {
5726 this._linkService
.page
= index
+ 1;
5729 this._eventBus
.dispatch("updatetextlayermatches", {
5736 this._eventBus
.dispatch("updatetextlayermatches", {
5743 const previous
= this._state
.findPrevious
;
5744 const currentPageIndex
= this._linkService
.page
- 1;
5745 const numPages
= this._linkService
.pagesCount
;
5746 this._highlightMatches
= true;
5748 if (this._dirtyMatch
) {
5749 this._dirtyMatch
= false;
5750 this._selected
.pageIdx
= this._selected
.matchIdx
= -1;
5751 this._offset
.pageIdx
= currentPageIndex
;
5752 this._offset
.matchIdx
= null;
5753 this._offset
.wrapped
= false;
5754 this._resumePageIdx
= null;
5755 this._pageMatches
.length
= 0;
5756 this._pageMatchesLength
.length
= 0;
5757 this._matchesCountTotal
= 0;
5759 this._updateAllPages();
5761 for (let i
= 0; i
< numPages
; i
++) {
5762 if (this._pendingFindMatches
.has(i
)) {
5766 this._pendingFindMatches
.add(i
);
5768 this._extractTextPromises
[i
].then(pageIdx
=> {
5769 this._pendingFindMatches
.delete(pageIdx
);
5771 this._calculateMatch(pageIdx
);
5776 if (this._query
=== "") {
5777 this._updateUIState(FindState
.FOUND
);
5782 if (this._resumePageIdx
) {
5786 const offset
= this._offset
;
5787 this._pagesToSearch
= numPages
;
5789 if (offset
.matchIdx
!== null) {
5790 const numPageMatches
= this._pageMatches
[offset
.pageIdx
].length
;
5792 if (!previous
&& offset
.matchIdx
+ 1 < numPageMatches
|| previous
&& offset
.matchIdx
> 0) {
5793 offset
.matchIdx
= previous
? offset
.matchIdx
- 1 : offset
.matchIdx
+ 1;
5795 this._updateMatch(true);
5800 this._advanceOffsetPage(previous
);
5803 this._nextPageMatch();
5806 _matchesReady(matches
) {
5807 const offset
= this._offset
;
5808 const numMatches
= matches
.length
;
5809 const previous
= this._state
.findPrevious
;
5812 offset
.matchIdx
= previous
? numMatches
- 1 : 0;
5814 this._updateMatch(true);
5819 this._advanceOffsetPage(previous
);
5821 if (offset
.wrapped
) {
5822 offset
.matchIdx
= null;
5824 if (this._pagesToSearch
< 0) {
5825 this._updateMatch(false);
5835 if (this._resumePageIdx
!== null) {
5836 console
.error("There can only be one pending page.");
5842 const pageIdx
= this._offset
.pageIdx
;
5843 matches
= this._pageMatches
[pageIdx
];
5846 this._resumePageIdx
= pageIdx
;
5849 } while (!this._matchesReady(matches
));
5852 _advanceOffsetPage(previous
) {
5853 const offset
= this._offset
;
5854 const numPages
= this._linkService
.pagesCount
;
5855 offset
.pageIdx
= previous
? offset
.pageIdx
- 1 : offset
.pageIdx
+ 1;
5856 offset
.matchIdx
= null;
5857 this._pagesToSearch
--;
5859 if (offset
.pageIdx
>= numPages
|| offset
.pageIdx
< 0) {
5860 offset
.pageIdx
= previous
? numPages
- 1 : 0;
5861 offset
.wrapped
= true;
5865 _updateMatch(found
= false) {
5866 let state
= FindState
.NOT_FOUND
;
5867 const wrapped
= this._offset
.wrapped
;
5868 this._offset
.wrapped
= false;
5871 const previousPage
= this._selected
.pageIdx
;
5872 this._selected
.pageIdx
= this._offset
.pageIdx
;
5873 this._selected
.matchIdx
= this._offset
.matchIdx
;
5874 state
= wrapped
? FindState
.WRAPPED
: FindState
.FOUND
;
5876 if (previousPage
!== -1 && previousPage
!== this._selected
.pageIdx
) {
5877 this._updatePage(previousPage
);
5881 this._updateUIState(state
, this._state
.findPrevious
);
5883 if (this._selected
.pageIdx
!== -1) {
5884 this._scrollMatches
= true;
5886 this._updatePage(this._selected
.pageIdx
);
5890 _onFindBarClose(evt
) {
5891 const pdfDocument
= this._pdfDocument
;
5893 this._firstPageCapability
.promise
.then(() => {
5894 if (!this._pdfDocument
|| pdfDocument
&& this._pdfDocument
!== pdfDocument
) {
5898 if (this._findTimeout
) {
5899 clearTimeout(this._findTimeout
);
5900 this._findTimeout
= null;
5903 if (this._resumePageIdx
) {
5904 this._resumePageIdx
= null;
5905 this._dirtyMatch
= true;
5908 this._updateUIState(FindState
.FOUND
);
5910 this._highlightMatches
= false;
5912 this._updateAllPages();
5916 _requestMatchesCount() {
5922 total
= this._matchesCountTotal
;
5924 if (matchIdx
!== -1) {
5925 for (let i
= 0; i
< pageIdx
; i
++) {
5926 current
+= this._pageMatches
[i
]?.length
|| 0;
5929 current
+= matchIdx
+ 1;
5932 if (current
< 1 || current
> total
) {
5933 current
= total
= 0;
5942 _updateUIResultsCount() {
5943 this._eventBus
.dispatch("updatefindmatchescount", {
5945 matchesCount
: this._requestMatchesCount()
5949 _updateUIState(state
, previous
) {
5950 this._eventBus
.dispatch("updatefindcontrolstate", {
5954 matchesCount
: this._requestMatchesCount(),
5955 rawQuery
: this._state
?.query
?? null
5961 exports
.PDFFindController
= PDFFindController
;
5965 /***/ ((__unused_webpack_module
, exports
) => {
5969 Object
.defineProperty(exports
, "__esModule", ({
5972 exports
.getCharacterType
= getCharacterType
;
5973 exports
.CharacterType
= void 0;
5974 const CharacterType
= {
5981 HALFWIDTH_KATAKANA_LETTER
: 6,
5984 exports
.CharacterType
= CharacterType
;
5986 function isAlphabeticalScript(charCode
) {
5987 return charCode
< 0x2e80;
5990 function isAscii(charCode
) {
5991 return (charCode
& 0xff80) === 0;
5994 function isAsciiAlpha(charCode
) {
5995 return charCode
>= 0x61 && charCode
<= 0x7a || charCode
>= 0x41 && charCode
<= 0x5a;
5998 function isAsciiDigit(charCode
) {
5999 return charCode
>= 0x30 && charCode
<= 0x39;
6002 function isAsciiSpace(charCode
) {
6003 return charCode
=== 0x20 || charCode
=== 0x09 || charCode
=== 0x0d || charCode
=== 0x0a;
6006 function isHan(charCode
) {
6007 return charCode
>= 0x3400 && charCode
<= 0x9fff || charCode
>= 0xf900 && charCode
<= 0xfaff;
6010 function isKatakana(charCode
) {
6011 return charCode
>= 0x30a0 && charCode
<= 0x30ff;
6014 function isHiragana(charCode
) {
6015 return charCode
>= 0x3040 && charCode
<= 0x309f;
6018 function isHalfwidthKatakana(charCode
) {
6019 return charCode
>= 0xff60 && charCode
<= 0xff9f;
6022 function isThai(charCode
) {
6023 return (charCode
& 0xff80) === 0x0e00;
6026 function getCharacterType(charCode
) {
6027 if (isAlphabeticalScript(charCode
)) {
6028 if (isAscii(charCode
)) {
6029 if (isAsciiSpace(charCode
)) {
6030 return CharacterType
.SPACE
;
6031 } else if (isAsciiAlpha(charCode
) || isAsciiDigit(charCode
) || charCode
=== 0x5f) {
6032 return CharacterType
.ALPHA_LETTER
;
6035 return CharacterType
.PUNCT
;
6036 } else if (isThai(charCode
)) {
6037 return CharacterType
.THAI_LETTER
;
6038 } else if (charCode
=== 0xa0) {
6039 return CharacterType
.SPACE
;
6042 return CharacterType
.ALPHA_LETTER
;
6045 if (isHan(charCode
)) {
6046 return CharacterType
.HAN_LETTER
;
6047 } else if (isKatakana(charCode
)) {
6048 return CharacterType
.KATAKANA_LETTER
;
6049 } else if (isHiragana(charCode
)) {
6050 return CharacterType
.HIRAGANA_LETTER
;
6051 } else if (isHalfwidthKatakana(charCode
)) {
6052 return CharacterType
.HALFWIDTH_KATAKANA_LETTER
;
6055 return CharacterType
.ALPHA_LETTER
;
6060 /***/ ((__unused_webpack_module
, exports
, __webpack_require__
) => {
6064 Object
.defineProperty(exports
, "__esModule", ({
6067 exports
.isDestArraysEqual
= isDestArraysEqual
;
6068 exports
.isDestHashesEqual
= isDestHashesEqual
;
6069 exports
.PDFHistory
= void 0;
6071 var _ui_utils
= __webpack_require__(4);
6073 const HASH_CHANGE_TIMEOUT
= 1000;
6074 const POSITION_UPDATED_THRESHOLD
= 50;
6075 const UPDATE_VIEWAREA_TIMEOUT
= 1000;
6077 function getCurrentHash() {
6078 return document
.location
.hash
;
6086 this.linkService
= linkService
;
6087 this.eventBus
= eventBus
;
6088 this._initialized
= false;
6089 this._fingerprint
= "";
6091 this._boundEvents
= null;
6092 this._isViewerInPresentationMode
= false;
6094 this.eventBus
._on("presentationmodechanged", evt
=> {
6095 this._isViewerInPresentationMode
= evt
.state
!== _ui_utils
.PresentationModeState
.NORMAL
;
6098 this.eventBus
._on("pagesinit", () => {
6099 this._isPagesLoaded
= false;
6101 this.eventBus
._on("pagesloaded", evt
=> {
6102 this._isPagesLoaded
= !!evt
.pagesCount
;
6111 resetHistory
= false,
6114 if (!fingerprint
|| typeof fingerprint
!== "string") {
6115 console
.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
6119 if (this._initialized
) {
6123 const reInitialized
= this._fingerprint
!== "" && this._fingerprint
!== fingerprint
;
6124 this._fingerprint
= fingerprint
;
6125 this._updateUrl
= updateUrl
=== true;
6126 this._initialized
= true;
6130 const state
= window
.history
.state
;
6131 this._popStateInProgress
= false;
6132 this._blockHashChange
= 0;
6133 this._currentHash
= getCurrentHash();
6134 this._numPositionUpdates
= 0;
6135 this._uid
= this._maxUid
= 0;
6136 this._destination
= null;
6137 this._position
= null;
6139 if (!this._isValidState(state
, true) || resetHistory
) {
6144 } = this._parseCurrentHash(true);
6146 if (!hash
|| reInitialized
|| resetHistory
) {
6147 this._pushOrReplaceState(null, true);
6152 this._pushOrReplaceState({
6161 const destination
= state
.destination
;
6163 this._updateInternalState(destination
, state
.uid
, true);
6165 if (destination
.rotation
!== undefined) {
6166 this._initialRotation
= destination
.rotation
;
6169 if (destination
.dest
) {
6170 this._initialBookmark
= JSON
.stringify(destination
.dest
);
6171 this._destination
.page
= null;
6172 } else if (destination
.hash
) {
6173 this._initialBookmark
= destination
.hash
;
6174 } else if (destination
.page
) {
6175 this._initialBookmark
= `page=${destination.page}`;
6180 if (this._initialized
) {
6183 this._initialized
= false;
6185 this._unbindEvents();
6188 if (this._updateViewareaTimeout
) {
6189 clearTimeout(this._updateViewareaTimeout
);
6190 this._updateViewareaTimeout
= null;
6193 this._initialBookmark
= null;
6194 this._initialRotation
= null;
6202 if (!this._initialized
) {
6206 if (namedDest
&& typeof namedDest
!== "string") {
6207 console
.error("PDFHistory.push: " + `"${namedDest}" is not a valid namedDest parameter.`);
6209 } else if (!Array
.isArray(explicitDest
)) {
6210 console
.error("PDFHistory.push: " + `"${explicitDest}" is not a valid explicitDest parameter.`);
6212 } else if (!this._isValidPage(pageNumber
)) {
6213 if (pageNumber
!== null || this._destination
) {
6214 console
.error("PDFHistory.push: " + `"${pageNumber}" is not a valid pageNumber parameter.`);
6219 const hash
= namedDest
|| JSON
.stringify(explicitDest
);
6225 let forceReplace
= false;
6227 if (this._destination
&& (isDestHashesEqual(this._destination
.hash
, hash
) || isDestArraysEqual(this._destination
.dest
, explicitDest
))) {
6228 if (this._destination
.page
) {
6232 forceReplace
= true;
6235 if (this._popStateInProgress
&& !forceReplace
) {
6239 this._pushOrReplaceState({
6243 rotation
: this.linkService
.rotation
6246 if (!this._popStateInProgress
) {
6247 this._popStateInProgress
= true;
6248 Promise
.resolve().then(() => {
6249 this._popStateInProgress
= false;
6254 pushPage(pageNumber
) {
6255 if (!this._initialized
) {
6259 if (!this._isValidPage(pageNumber
)) {
6260 console
.error(`PDFHistory.pushPage: "${pageNumber}" is not a valid page number.`);
6264 if (this._destination
?.page
=== pageNumber
) {
6268 if (this._popStateInProgress
) {
6272 this._pushOrReplaceState({
6274 hash
: `page=${pageNumber}`,
6276 rotation
: this.linkService
.rotation
6279 if (!this._popStateInProgress
) {
6280 this._popStateInProgress
= true;
6281 Promise
.resolve().then(() => {
6282 this._popStateInProgress
= false;
6287 pushCurrentPosition() {
6288 if (!this._initialized
|| this._popStateInProgress
) {
6292 this._tryPushCurrentPosition();
6296 if (!this._initialized
|| this._popStateInProgress
) {
6300 const state
= window
.history
.state
;
6302 if (this._isValidState(state
) && state
.uid
> 0) {
6303 window
.history
.back();
6308 if (!this._initialized
|| this._popStateInProgress
) {
6312 const state
= window
.history
.state
;
6314 if (this._isValidState(state
) && state
.uid
< this._maxUid
) {
6315 window
.history
.forward();
6319 get popStateInProgress() {
6320 return this._initialized
&& (this._popStateInProgress
|| this._blockHashChange
> 0);
6323 get initialBookmark() {
6324 return this._initialized
? this._initialBookmark
: null;
6327 get initialRotation() {
6328 return this._initialized
? this._initialRotation
: null;
6331 _pushOrReplaceState(destination
, forceReplace
= false) {
6332 const shouldReplace
= forceReplace
|| !this._destination
;
6334 fingerprint
: this._fingerprint
,
6335 uid
: shouldReplace
? this._uid
: this._uid
+ 1,
6339 this._updateInternalState(destination
, newState
.uid
);
6343 if (this._updateUrl
&& destination
?.hash
) {
6344 const baseUrl
= document
.location
.href
.split("#")[0];
6346 if (!baseUrl
.startsWith("file://")) {
6347 newUrl
= `${baseUrl}#${destination.hash}`;
6351 if (shouldReplace
) {
6352 window
.history
.replaceState(newState
, "", newUrl
);
6354 window
.history
.pushState(newState
, "", newUrl
);
6358 _tryPushCurrentPosition(temporary
= false) {
6359 if (!this._position
) {
6363 let position
= this._position
;
6366 position
= Object
.assign(Object
.create(null), this._position
);
6367 position
.temporary
= true;
6370 if (!this._destination
) {
6371 this._pushOrReplaceState(position
);
6376 if (this._destination
.temporary
) {
6377 this._pushOrReplaceState(position
, true);
6382 if (this._destination
.hash
=== position
.hash
) {
6386 if (!this._destination
.page
&& (POSITION_UPDATED_THRESHOLD
<= 0 || this._numPositionUpdates
<= POSITION_UPDATED_THRESHOLD
)) {
6390 let forceReplace
= false;
6392 if (this._destination
.page
>= position
.first
&& this._destination
.page
<= position
.page
) {
6393 if (this._destination
.dest
!== undefined || !this._destination
.first
) {
6397 forceReplace
= true;
6400 this._pushOrReplaceState(position
, forceReplace
);
6404 return Number
.isInteger(val
) && val
> 0 && val
<= this.linkService
.pagesCount
;
6407 _isValidState(state
, checkReload
= false) {
6412 if (state
.fingerprint
!== this._fingerprint
) {
6414 if (typeof state
.fingerprint
!== "string" || state
.fingerprint
.length
!== this._fingerprint
.length
) {
6418 const [perfEntry
] = performance
.getEntriesByType("navigation");
6420 if (perfEntry
?.type
!== "reload") {
6428 if (!Number
.isInteger(state
.uid
) || state
.uid
< 0) {
6432 if (state
.destination
=== null || typeof state
.destination
!== "object") {
6439 _updateInternalState(destination
, uid
, removeTemporary
= false) {
6440 if (this._updateViewareaTimeout
) {
6441 clearTimeout(this._updateViewareaTimeout
);
6442 this._updateViewareaTimeout
= null;
6445 if (removeTemporary
&& destination
?.temporary
) {
6446 delete destination
.temporary
;
6449 this._destination
= destination
;
6451 this._maxUid
= Math
.max(this._maxUid
, uid
);
6452 this._numPositionUpdates
= 0;
6455 _parseCurrentHash(checkNameddest
= false) {
6456 const hash
= unescape(getCurrentHash()).substring(1);
6457 const params
= (0, _ui_utils
.parseQueryString
)(hash
);
6458 const nameddest
= params
.nameddest
|| "";
6459 let page
= params
.page
| 0;
6461 if (!this._isValidPage(page
) || checkNameddest
&& nameddest
.length
> 0) {
6468 rotation
: this.linkService
.rotation
6475 if (this._updateViewareaTimeout
) {
6476 clearTimeout(this._updateViewareaTimeout
);
6477 this._updateViewareaTimeout
= null;
6481 hash
: this._isViewerInPresentationMode
? `page=${location.pageNumber}` : location
.pdfOpenParams
.substring(1),
6482 page
: this.linkService
.page
,
6483 first
: location
.pageNumber
,
6484 rotation
: location
.rotation
6487 if (this._popStateInProgress
) {
6491 if (POSITION_UPDATED_THRESHOLD
> 0 && this._isPagesLoaded
&& this._destination
&& !this._destination
.page
) {
6492 this._numPositionUpdates
++;
6495 if (UPDATE_VIEWAREA_TIMEOUT
> 0) {
6496 this._updateViewareaTimeout
= setTimeout(() => {
6497 if (!this._popStateInProgress
) {
6498 this._tryPushCurrentPosition(true);
6501 this._updateViewareaTimeout
= null;
6502 }, UPDATE_VIEWAREA_TIMEOUT
);
6509 const newHash
= getCurrentHash(),
6510 hashChanged
= this._currentHash
!== newHash
;
6511 this._currentHash
= newHash
;
6520 } = this._parseCurrentHash();
6522 this._pushOrReplaceState({
6531 if (!this._isValidState(state
)) {
6535 this._popStateInProgress
= true;
6538 this._blockHashChange
++;
6539 (0, _ui_utils
.waitOnEventOrTimeout
)({
6542 delay
: HASH_CHANGE_TIMEOUT
6544 this._blockHashChange
--;
6548 const destination
= state
.destination
;
6550 this._updateInternalState(destination
, state
.uid
, true);
6552 if ((0, _ui_utils
.isValidRotation
)(destination
.rotation
)) {
6553 this.linkService
.rotation
= destination
.rotation
;
6556 if (destination
.dest
) {
6557 this.linkService
.goToDestination(destination
.dest
);
6558 } else if (destination
.hash
) {
6559 this.linkService
.setHash(destination
.hash
);
6560 } else if (destination
.page
) {
6561 this.linkService
.page
= destination
.page
;
6564 Promise
.resolve().then(() => {
6565 this._popStateInProgress
= false;
6570 if (!this._destination
|| this._destination
.temporary
) {
6571 this._tryPushCurrentPosition();
6576 if (this._boundEvents
) {
6580 this._boundEvents
= {
6581 updateViewarea
: this._updateViewarea
.bind(this),
6582 popState
: this._popState
.bind(this),
6583 pageHide
: this._pageHide
.bind(this)
6586 this.eventBus
._on("updateviewarea", this._boundEvents
.updateViewarea
);
6588 window
.addEventListener("popstate", this._boundEvents
.popState
);
6589 window
.addEventListener("pagehide", this._boundEvents
.pageHide
);
6593 if (!this._boundEvents
) {
6597 this.eventBus
._off("updateviewarea", this._boundEvents
.updateViewarea
);
6599 window
.removeEventListener("popstate", this._boundEvents
.popState
);
6600 window
.removeEventListener("pagehide", this._boundEvents
.pageHide
);
6601 this._boundEvents
= null;
6606 exports
.PDFHistory
= PDFHistory
;
6608 function isDestHashesEqual(destHash
, pushHash
) {
6609 if (typeof destHash
!== "string" || typeof pushHash
!== "string") {
6613 if (destHash
=== pushHash
) {
6619 } = (0, _ui_utils
.parseQueryString
)(destHash
);
6621 if (nameddest
=== pushHash
) {
6628 function isDestArraysEqual(firstDest
, secondDest
) {
6629 function isEntryEqual(first
, second
) {
6630 if (typeof first
!== typeof second
) {
6634 if (Array
.isArray(first
) || Array
.isArray(second
)) {
6638 if (first
!== null && typeof first
=== "object" && second
!== null) {
6639 if (Object
.keys(first
).length
!== Object
.keys(second
).length
) {
6643 for (const key
in first
) {
6644 if (!isEntryEqual(first
[key
], second
[key
])) {
6652 return first
=== second
|| Number
.isNaN(first
) && Number
.isNaN(second
);
6655 if (!(Array
.isArray(firstDest
) && Array
.isArray(secondDest
))) {
6659 if (firstDest
.length
!== secondDest
.length
) {
6663 for (let i
= 0, ii
= firstDest
.length
; i
< ii
; i
++) {
6664 if (!isEntryEqual(firstDest
[i
], secondDest
[i
])) {
6674 /***/ ((__unused_webpack_module
, exports
, __webpack_require__
) => {
6678 Object
.defineProperty(exports
, "__esModule", ({
6681 exports
.PDFLayerViewer
= void 0;
6683 var _base_tree_viewer
= __webpack_require__(12);
6685 class PDFLayerViewer
extends _base_tree_viewer
.BaseTreeViewer
{
6686 constructor(options
) {
6688 this.l10n
= options
.l10n
;
6690 this.eventBus
._on("resetlayers", this._resetLayers
.bind(this));
6692 this.eventBus
._on("togglelayerstree", this._toggleAllTreeItems
.bind(this));
6697 this._optionalContentConfig
= null;
6700 _dispatchEvent(layersCount
) {
6701 this.eventBus
.dispatch("layersloaded", {
6707 _bindLink(element
, {
6711 const setVisibility
= () => {
6712 this._optionalContentConfig
.setVisibility(groupId
, input
.checked
);
6714 this.eventBus
.dispatch("optionalcontentconfig", {
6716 promise
: Promise
.resolve(this._optionalContentConfig
)
6720 element
.onclick
= evt
=> {
6721 if (evt
.target
=== input
) {
6724 } else if (evt
.target
!== element
) {
6728 input
.checked
= !input
.checked
;
6734 async
_setNestedName(element
, {
6737 if (typeof name
=== "string") {
6738 element
.textContent
= this._normalizeTextContent(name
);
6742 element
.textContent
= await
this.l10n
.get("additional_layers");
6743 element
.style
.fontStyle
= "italic";
6746 _addToggleButton(div
, {
6749 super._addToggleButton(div
, name
=== null);
6752 _toggleAllTreeItems() {
6753 if (!this._optionalContentConfig
) {
6757 super._toggleAllTreeItems();
6761 optionalContentConfig
,
6764 if (this._optionalContentConfig
) {
6768 this._optionalContentConfig
= optionalContentConfig
|| null;
6769 this._pdfDocument
= pdfDocument
|| null;
6770 const groups
= optionalContentConfig
?.getOrder();
6773 this._dispatchEvent(0);
6778 const fragment
= document
.createDocumentFragment(),
6783 let layersCount
= 0,
6784 hasAnyNesting
= false;
6786 while (queue
.length
> 0) {
6787 const levelData
= queue
.shift();
6789 for (const groupId
of levelData
.groups
) {
6790 const div
= document
.createElement("div");
6791 div
.className
= "treeItem";
6792 const element
= document
.createElement("a");
6793 div
.appendChild(element
);
6795 if (typeof groupId
=== "object") {
6796 hasAnyNesting
= true;
6798 this._addToggleButton(div
, groupId
);
6800 this._setNestedName(element
, groupId
);
6802 const itemsDiv
= document
.createElement("div");
6803 itemsDiv
.className
= "treeItems";
6804 div
.appendChild(itemsDiv
);
6807 groups
: groupId
.order
6810 const group
= optionalContentConfig
.getGroup(groupId
);
6811 const input
= document
.createElement("input");
6813 this._bindLink(element
, {
6818 input
.type
= "checkbox";
6820 input
.checked
= group
.visible
;
6821 const label
= document
.createElement("label");
6822 label
.setAttribute("for", groupId
);
6823 label
.textContent
= this._normalizeTextContent(group
.name
);
6824 element
.appendChild(input
);
6825 element
.appendChild(label
);
6829 levelData
.parent
.appendChild(div
);
6833 this._finishRendering(fragment
, layersCount
, hasAnyNesting
);
6836 async
_resetLayers() {
6837 if (!this._optionalContentConfig
) {
6841 const optionalContentConfig
= await
this._pdfDocument
.getOptionalContentConfig();
6842 this.eventBus
.dispatch("optionalcontentconfig", {
6844 promise
: Promise
.resolve(optionalContentConfig
)
6847 optionalContentConfig
,
6848 pdfDocument
: this._pdfDocument
6854 exports
.PDFLayerViewer
= PDFLayerViewer
;
6858 /***/ ((__unused_webpack_module
, exports
, __webpack_require__
) => {
6862 Object
.defineProperty(exports
, "__esModule", ({
6865 exports
.SimpleLinkService
= exports
.PDFLinkService
= void 0;
6867 var _ui_utils
= __webpack_require__(4);
6869 class PDFLinkService
{
6872 externalLinkTarget
= null,
6873 externalLinkRel
= null,
6874 ignoreDestinationZoom
= false
6876 this.eventBus
= eventBus
;
6877 this.externalLinkTarget
= externalLinkTarget
;
6878 this.externalLinkRel
= externalLinkRel
;
6879 this.externalLinkEnabled
= true;
6880 this._ignoreDestinationZoom
= ignoreDestinationZoom
;
6881 this.baseUrl
= null;
6882 this.pdfDocument
= null;
6883 this.pdfViewer
= null;
6884 this.pdfHistory
= null;
6885 this._pagesRefCache
= null;
6888 setDocument(pdfDocument
, baseUrl
= null) {
6889 this.baseUrl
= baseUrl
;
6890 this.pdfDocument
= pdfDocument
;
6891 this._pagesRefCache
= Object
.create(null);
6894 setViewer(pdfViewer
) {
6895 this.pdfViewer
= pdfViewer
;
6898 setHistory(pdfHistory
) {
6899 this.pdfHistory
= pdfHistory
;
6903 return this.pdfDocument
? this.pdfDocument
.numPages
: 0;
6907 return this.pdfViewer
.currentPageNumber
;
6911 this.pdfViewer
.currentPageNumber
= value
;
6915 return this.pdfViewer
.pagesRotation
;
6918 set rotation(value
) {
6919 this.pdfViewer
.pagesRotation
= value
;
6922 _goToDestinationHelper(rawDest
, namedDest
= null, explicitDest
) {
6923 const destRef
= explicitDest
[0];
6926 if (typeof destRef
=== "object" && destRef
!== null) {
6927 pageNumber
= this._cachedPageNumber(destRef
);
6929 if (pageNumber
=== null) {
6930 this.pdfDocument
.getPageIndex(destRef
).then(pageIndex
=> {
6931 this.cachePageRef(pageIndex
+ 1, destRef
);
6933 this._goToDestinationHelper(rawDest
, namedDest
, explicitDest
);
6935 console
.error(`PDFLinkService._goToDestinationHelper: "${destRef}" is not ` + `a valid page reference, for dest="${rawDest}".`);
6939 } else if (Number
.isInteger(destRef
)) {
6940 pageNumber
= destRef
+ 1;
6942 console
.error(`PDFLinkService._goToDestinationHelper: "${destRef}" is not ` + `a valid destination reference, for dest="${rawDest}".`);
6946 if (!pageNumber
|| pageNumber
< 1 || pageNumber
> this.pagesCount
) {
6947 console
.error(`PDFLinkService._goToDestinationHelper: "${pageNumber}" is not ` + `a valid page number, for dest="${rawDest}".`);
6951 if (this.pdfHistory
) {
6952 this.pdfHistory
.pushCurrentPosition();
6953 this.pdfHistory
.push({
6960 this.pdfViewer
.scrollPageIntoView({
6962 destArray
: explicitDest
,
6963 ignoreDestinationZoom
: this._ignoreDestinationZoom
6967 async
goToDestination(dest
) {
6968 if (!this.pdfDocument
) {
6972 let namedDest
, explicitDest
;
6974 if (typeof dest
=== "string") {
6976 explicitDest
= await
this.pdfDocument
.getDestination(dest
);
6979 explicitDest
= await dest
;
6982 if (!Array
.isArray(explicitDest
)) {
6983 console
.error(`PDFLinkService.goToDestination: "${explicitDest}" is not ` + `a valid destination array, for dest="${dest}".`);
6987 this._goToDestinationHelper(dest
, namedDest
, explicitDest
);
6991 if (!this.pdfDocument
) {
6995 const pageNumber
= typeof val
=== "string" && this.pdfViewer
.pageLabelToPageNumber(val
) || val
| 0;
6997 if (!(Number
.isInteger(pageNumber
) && pageNumber
> 0 && pageNumber
<= this.pagesCount
)) {
6998 console
.error(`PDFLinkService.goToPage: "${val}" is not a valid page.`);
7002 if (this.pdfHistory
) {
7003 this.pdfHistory
.pushCurrentPosition();
7004 this.pdfHistory
.pushPage(pageNumber
);
7007 this.pdfViewer
.scrollPageIntoView({
7012 getDestinationHash(dest
) {
7013 if (typeof dest
=== "string") {
7014 if (dest
.length
> 0) {
7015 return this.getAnchorUrl("#" + escape(dest
));
7017 } else if (Array
.isArray(dest
)) {
7018 const str
= JSON
.stringify(dest
);
7020 if (str
.length
> 0) {
7021 return this.getAnchorUrl("#" + escape(str
));
7025 return this.getAnchorUrl("");
7028 getAnchorUrl(anchor
) {
7029 return (this.baseUrl
|| "") + anchor
;
7033 if (!this.pdfDocument
) {
7037 let pageNumber
, dest
;
7039 if (hash
.includes("=")) {
7040 const params
= (0, _ui_utils
.parseQueryString
)(hash
);
7042 if ("search" in params
) {
7043 this.eventBus
.dispatch("findfromurlhash", {
7045 query
: params
.search
.replace(/"/g, ""),
7046 phraseSearch: params.phrase === "true"
7050 if ("page
" in params) {
7051 pageNumber = params.page | 0 || 1;
7054 if ("zoom
" in params) {
7055 const zoomArgs = params.zoom.split(",");
7056 const zoomArg = zoomArgs[0];
7057 const zoomArgNumber = parseFloat(zoomArg);
7059 if (!zoomArg.includes("Fit
")) {
7062 }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
7064 if (zoomArg === "Fit
" || zoomArg === "FitB
") {
7068 } else if (zoomArg === "FitH
" || zoomArg === "FitBH
" || zoomArg === "FitV
" || zoomArg === "FitBV
") {
7071 }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
7072 } else if (zoomArg === "FitR
") {
7073 if (zoomArgs.length !== 5) {
7074 console.error('PDFLinkService.setHash: Not enough parameters for "FitR
".');
7078 }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
7081 console.error(`PDFLinkService.setHash: "${zoomArg}
" is not ` + "a valid zoom value
.");
7087 this.pdfViewer.scrollPageIntoView({
7088 pageNumber: pageNumber || this.page,
7090 allowNegativeOffset: true
7092 } else if (pageNumber) {
7093 this.page = pageNumber;
7096 if ("pagemode
" in params) {
7097 this.eventBus.dispatch("pagemode
", {
7099 mode: params.pagemode
7103 if ("nameddest
" in params) {
7104 this.goToDestination(params.nameddest);
7107 dest = unescape(hash);
7110 dest = JSON.parse(dest);
7112 if (!Array.isArray(dest)) {
7113 dest = dest.toString();
7117 if (typeof dest === "string
" || isValidExplicitDestination(dest)) {
7118 this.goToDestination(dest);
7122 console.error(`PDFLinkService.setHash: "${unescape(hash)}
" is not ` + "a valid destination
.");
7126 executeNamedAction(action) {
7129 if (this.pdfHistory) {
7130 this.pdfHistory.back();
7136 if (this.pdfHistory) {
7137 this.pdfHistory.forward();
7143 this.pdfViewer.nextPage();
7147 this.pdfViewer.previousPage();
7151 this.page = this.pagesCount;
7162 this.eventBus.dispatch("namedaction
", {
7168 cachePageRef(pageNum, pageRef) {
7173 const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
7174 this._pagesRefCache[refStr] = pageNum;
7177 _cachedPageNumber(pageRef) {
7178 const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
7179 return this._pagesRefCache?.[refStr] || null;
7182 isPageVisible(pageNumber) {
7183 return this.pdfViewer.isPageVisible(pageNumber);
7186 isPageCached(pageNumber) {
7187 return this.pdfViewer.isPageCached(pageNumber);
7192 exports.PDFLinkService = PDFLinkService;
7194 function isValidExplicitDestination(dest) {
7195 if (!Array.isArray(dest)) {
7199 const destLength = dest.length;
7201 if (destLength < 2) {
7205 const page = dest[0];
7207 if (!(typeof page === "object
" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
7211 const zoom = dest[1];
7213 if (!(typeof zoom === "object
" && typeof zoom.name === "string
")) {
7217 let allowNull = true;
7219 switch (zoom.name) {
7221 if (destLength !== 5) {
7229 return destLength === 2;
7235 if (destLength !== 3) {
7242 if (destLength !== 6) {
7253 for (let i = 2; i < destLength; i++) {
7254 const param = dest[i];
7256 if (!(typeof param === "number
" || allowNull && param === null)) {
7264 class SimpleLinkService {
7266 this.externalLinkTarget = null;
7267 this.externalLinkRel = null;
7268 this.externalLinkEnabled = true;
7269 this._ignoreDestinationZoom = false;
7286 set rotation(value) {}
7288 async goToDestination(dest) {}
7292 getDestinationHash(dest) {
7296 getAnchorUrl(hash) {
7302 executeNamedAction(action) {}
7304 cachePageRef(pageNum, pageRef) {}
7306 isPageVisible(pageNumber) {
7310 isPageCached(pageNumber) {
7316 exports.SimpleLinkService = SimpleLinkService;
7320 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
7324 Object.defineProperty(exports, "__esModule
", ({
7327 exports.PDFOutlineViewer = void 0;
7329 var _pdfjsLib = __webpack_require__(5);
7331 var _base_tree_viewer = __webpack_require__(12);
7333 var _ui_utils = __webpack_require__(4);
7335 class PDFOutlineViewer extends _base_tree_viewer.BaseTreeViewer {
7336 constructor(options) {
7338 this.linkService = options.linkService;
7340 this.eventBus._on("toggleoutlinetree
", this._toggleAllTreeItems.bind(this));
7342 this.eventBus._on("currentoutlineitem
", this._currentOutlineItem.bind(this));
7344 this.eventBus._on("pagechanging
", evt => {
7345 this._currentPageNumber = evt.pageNumber;
7348 this.eventBus._on("pagesloaded
", evt => {
7349 this._isPagesLoaded = !!evt.pagesCount;
7351 if (this._currentOutlineItemCapability && !this._currentOutlineItemCapability.settled) {
7352 this._currentOutlineItemCapability.resolve(this._isPagesLoaded);
7356 this.eventBus._on("sidebarviewchanged
", evt => {
7357 this._sidebarView = evt.view;
7363 this._outline = null;
7364 this._pageNumberToDestHashCapability = null;
7365 this._currentPageNumber = 1;
7366 this._isPagesLoaded = false;
7368 if (this._currentOutlineItemCapability && !this._currentOutlineItemCapability.settled) {
7369 this._currentOutlineItemCapability.resolve(false);
7372 this._currentOutlineItemCapability = null;
7375 _dispatchEvent(outlineCount) {
7376 this._currentOutlineItemCapability = (0, _pdfjsLib.createPromiseCapability)();
7378 if (outlineCount === 0 || this._pdfDocument?.loadingParams.disableAutoFetch) {
7379 this._currentOutlineItemCapability.resolve(false);
7380 } else if (this._isPagesLoaded) {
7381 this._currentOutlineItemCapability.resolve(true);
7384 this.eventBus.dispatch("outlineloaded
", {
7387 currentOutlineItemPromise: this._currentOutlineItemCapability.promise
7391 _bindLink(element, {
7401 (0, _pdfjsLib.addLinkAttributes)(element, {
7403 target: newWindow ? _pdfjsLib.LinkTarget.BLANK : linkService.externalLinkTarget,
7404 rel: linkService.externalLinkRel,
7405 enabled: linkService.externalLinkEnabled
7410 element.href = linkService.getDestinationHash(dest);
7412 element.onclick = evt => {
7413 this._updateCurrentTreeItem(evt.target.parentNode);
7416 linkService.goToDestination(dest);
7423 _setStyles(element, {
7428 element.style.fontWeight = "bold
";
7432 element.style.fontStyle = "italic
";
7436 _addToggleButton(div, {
7443 let totalCount = items.length;
7445 if (totalCount > 0) {
7446 const queue = [...items];
7448 while (queue.length > 0) {
7454 if (nestedCount > 0 && nestedItems.length > 0) {
7455 totalCount += nestedItems.length;
7456 queue.push(...nestedItems);
7461 if (Math.abs(count) === totalCount) {
7466 super._addToggleButton(div, hidden);
7469 _toggleAllTreeItems() {
7470 if (!this._outline) {
7474 super._toggleAllTreeItems();
7481 if (this._outline) {
7485 this._outline = outline || null;
7486 this._pdfDocument = pdfDocument || null;
7489 this._dispatchEvent(0);
7494 const fragment = document.createDocumentFragment();
7499 let outlineCount = 0,
7500 hasAnyNesting = false;
7502 while (queue.length > 0) {
7503 const levelData = queue.shift();
7505 for (const item of levelData.items) {
7506 const div = document.createElement("div
");
7507 div.className = "treeItem
";
7508 const element = document.createElement("a
");
7510 this._bindLink(element, item);
7512 this._setStyles(element, item);
7514 element.textContent = this._normalizeTextContent(item.title);
7515 div.appendChild(element);
7517 if (item.items.length > 0) {
7518 hasAnyNesting = true;
7520 this._addToggleButton(div, item);
7522 const itemsDiv = document.createElement("div
");
7523 itemsDiv.className = "treeItems
";
7524 div.appendChild(itemsDiv);
7531 levelData.parent.appendChild(div);
7536 this._finishRendering(fragment, outlineCount, hasAnyNesting);
7539 async _currentOutlineItem() {
7540 if (!this._isPagesLoaded) {
7541 throw new Error("_currentOutlineItem
: All pages have not been loaded
.");
7544 if (!this._outline || !this._pdfDocument) {
7548 const pageNumberToDestHash = await this._getPageNumberToDestHash(this._pdfDocument);
7550 if (!pageNumberToDestHash) {
7554 this._updateCurrentTreeItem(null);
7556 if (this._sidebarView !== _ui_utils.SidebarView.OUTLINE) {
7560 for (let i = this._currentPageNumber; i > 0; i--) {
7561 const destHash = pageNumberToDestHash.get(i);
7567 const linkElement = this.container.querySelector(`a[href="${destHash}
"]`);
7573 this._scrollToCurrentTreeItem(linkElement.parentNode);
7579 async _getPageNumberToDestHash(pdfDocument) {
7580 if (this._pageNumberToDestHashCapability) {
7581 return this._pageNumberToDestHashCapability.promise;
7584 this._pageNumberToDestHashCapability = (0, _pdfjsLib.createPromiseCapability)();
7585 const pageNumberToDestHash = new Map(),
7586 pageNumberNesting = new Map();
7589 items: this._outline
7592 while (queue.length > 0) {
7593 const levelData = queue.shift(),
7594 currentNesting = levelData.nesting;
7599 } of levelData.items) {
7600 let explicitDest, pageNumber;
7602 if (typeof dest === "string
") {
7603 explicitDest = await pdfDocument.getDestination(dest);
7605 if (pdfDocument !== this._pdfDocument) {
7609 explicitDest = dest;
7612 if (Array.isArray(explicitDest)) {
7613 const [destRef] = explicitDest;
7615 if (typeof destRef === "object
" && destRef !== null) {
7616 pageNumber = this.linkService._cachedPageNumber(destRef);
7620 pageNumber = (await pdfDocument.getPageIndex(destRef)) + 1;
7622 if (pdfDocument !== this._pdfDocument) {
7626 this.linkService.cachePageRef(pageNumber, destRef);
7629 } else if (Number.isInteger(destRef)) {
7630 pageNumber = destRef + 1;
7633 if (Number.isInteger(pageNumber) && (!pageNumberToDestHash.has(pageNumber) || currentNesting > pageNumberNesting.get(pageNumber))) {
7634 const destHash = this.linkService.getDestinationHash(dest);
7635 pageNumberToDestHash.set(pageNumber, destHash);
7636 pageNumberNesting.set(pageNumber, currentNesting);
7640 if (items.length > 0) {
7642 nesting: currentNesting + 1,
7649 this._pageNumberToDestHashCapability.resolve(pageNumberToDestHash.size > 0 ? pageNumberToDestHash : null);
7651 return this._pageNumberToDestHashCapability.promise;
7656 exports.PDFOutlineViewer = PDFOutlineViewer;
7660 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
7664 Object.defineProperty(exports, "__esModule
", ({
7667 exports.PDFPresentationMode = void 0;
7669 var _ui_utils = __webpack_require__(4);
7671 const DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
7672 const DELAY_BEFORE_HIDING_CONTROLS = 3000;
7673 const ACTIVE_SELECTOR = "pdfPresentationMode
";
7674 const CONTROLS_SELECTOR = "pdfPresentationModeControls
";
7675 const MOUSE_SCROLL_COOLDOWN_TIME = 50;
7676 const PAGE_SWITCH_THRESHOLD = 0.1;
7677 const SWIPE_MIN_DISTANCE_THRESHOLD = 50;
7678 const SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
7680 class PDFPresentationMode {
7686 this.container = container;
7687 this.pdfViewer = pdfViewer;
7688 this.eventBus = eventBus;
7689 this.active = false;
7691 this.contextMenuOpen = false;
7692 this.mouseScrollTimeStamp = 0;
7693 this.mouseScrollDelta = 0;
7694 this.touchSwipeState = null;
7698 if (this.switchInProgress || this.active || !this.pdfViewer.pagesCount) {
7702 this._addFullscreenChangeListeners();
7704 this._setSwitchInProgress();
7706 this._notifyStateChange();
7708 if (this.container.requestFullscreen) {
7709 this.container.requestFullscreen();
7710 } else if (this.container.mozRequestFullScreen) {
7711 this.container.mozRequestFullScreen();
7712 } else if (this.container.webkitRequestFullscreen) {
7713 this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
7719 page: this.pdfViewer.currentPageNumber,
7720 previousScale: this.pdfViewer.currentScaleValue
7730 evt.preventDefault();
7731 const delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
7732 const currentTime = Date.now();
7733 const storedTime = this.mouseScrollTimeStamp;
7735 if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
7739 if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
7740 this._resetMouseScrollState();
7743 this.mouseScrollDelta += delta;
7745 if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
7746 const totalDelta = this.mouseScrollDelta;
7748 this._resetMouseScrollState();
7750 const success = totalDelta > 0 ? this.pdfViewer.previousPage() : this.pdfViewer.nextPage();
7753 this.mouseScrollTimeStamp = currentTime;
7758 get isFullscreen() {
7759 return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen);
7762 _notifyStateChange() {
7763 let state = _ui_utils.PresentationModeState.NORMAL;
7765 if (this.switchInProgress) {
7766 state = _ui_utils.PresentationModeState.CHANGING;
7767 } else if (this.active) {
7768 state = _ui_utils.PresentationModeState.FULLSCREEN;
7771 this.eventBus.dispatch("presentationmodechanged
", {
7777 _setSwitchInProgress() {
7778 if (this.switchInProgress) {
7779 clearTimeout(this.switchInProgress);
7782 this.switchInProgress = setTimeout(() => {
7783 this._removeFullscreenChangeListeners();
7785 delete this.switchInProgress;
7787 this._notifyStateChange();
7788 }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
7791 _resetSwitchInProgress() {
7792 if (this.switchInProgress) {
7793 clearTimeout(this.switchInProgress);
7794 delete this.switchInProgress;
7801 this._resetSwitchInProgress();
7803 this._notifyStateChange();
7805 this.container.classList.add(ACTIVE_SELECTOR);
7807 this.pdfViewer.currentPageNumber = this.args.page;
7808 this.pdfViewer.currentScaleValue = "page
-fit
";
7811 this._addWindowListeners();
7813 this._showControls();
7815 this.contextMenuOpen = false;
7816 window.getSelection().removeAllRanges();
7820 const page = this.pdfViewer.currentPageNumber;
7821 this.container.classList.remove(ACTIVE_SELECTOR);
7823 this.active = false;
7825 this._removeFullscreenChangeListeners();
7827 this._notifyStateChange();
7829 this.pdfViewer.currentScaleValue = this.args.previousScale;
7830 this.pdfViewer.currentPageNumber = page;
7834 this._removeWindowListeners();
7836 this._hideControls();
7838 this._resetMouseScrollState();
7840 this.contextMenuOpen = false;
7844 if (this.contextMenuOpen) {
7845 this.contextMenuOpen = false;
7846 evt.preventDefault();
7850 if (evt.button === 0) {
7851 const isInternalLink = evt.target.href && evt.target.classList.contains("internalLink
");
7853 if (!isInternalLink) {
7854 evt.preventDefault();
7857 this.pdfViewer.previousPage();
7859 this.pdfViewer.nextPage();
7866 this.contextMenuOpen = true;
7870 if (this.controlsTimeout) {
7871 clearTimeout(this.controlsTimeout);
7873 this.container.classList.add(CONTROLS_SELECTOR);
7876 this.controlsTimeout = setTimeout(() => {
7877 this.container.classList.remove(CONTROLS_SELECTOR);
7878 delete this.controlsTimeout;
7879 }, DELAY_BEFORE_HIDING_CONTROLS);
7883 if (!this.controlsTimeout) {
7887 clearTimeout(this.controlsTimeout);
7888 this.container.classList.remove(CONTROLS_SELECTOR);
7889 delete this.controlsTimeout;
7892 _resetMouseScrollState() {
7893 this.mouseScrollTimeStamp = 0;
7894 this.mouseScrollDelta = 0;
7902 if (evt.touches.length > 1) {
7903 this.touchSwipeState = null;
7909 this.touchSwipeState = {
7910 startX: evt.touches[0].pageX,
7911 startY: evt.touches[0].pageY,
7912 endX: evt.touches[0].pageX,
7913 endY: evt.touches[0].pageY
7918 if (this.touchSwipeState === null) {
7922 this.touchSwipeState.endX = evt.touches[0].pageX;
7923 this.touchSwipeState.endY = evt.touches[0].pageY;
7924 evt.preventDefault();
7928 if (this.touchSwipeState === null) {
7933 const dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
7934 const dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
7935 const absAngle = Math.abs(Math.atan2(dy, dx));
7937 if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
7939 } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
7944 this.pdfViewer.previousPage();
7945 } else if (delta < 0) {
7946 this.pdfViewer.nextPage();
7953 _addWindowListeners() {
7954 this.showControlsBind = this._showControls.bind(this);
7955 this.mouseDownBind = this._mouseDown.bind(this);
7956 this.mouseWheelBind = this._mouseWheel.bind(this);
7957 this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
7958 this.contextMenuBind = this._contextMenu.bind(this);
7959 this.touchSwipeBind = this._touchSwipe.bind(this);
7960 window.addEventListener("mousemove
", this.showControlsBind);
7961 window.addEventListener("mousedown
", this.mouseDownBind);
7962 window.addEventListener("wheel
", this.mouseWheelBind, {
7965 window.addEventListener("keydown
", this.resetMouseScrollStateBind);
7966 window.addEventListener("contextmenu
", this.contextMenuBind);
7967 window.addEventListener("touchstart
", this.touchSwipeBind);
7968 window.addEventListener("touchmove
", this.touchSwipeBind);
7969 window.addEventListener("touchend
", this.touchSwipeBind);
7972 _removeWindowListeners() {
7973 window.removeEventListener("mousemove
", this.showControlsBind);
7974 window.removeEventListener("mousedown
", this.mouseDownBind);
7975 window.removeEventListener("wheel
", this.mouseWheelBind, {
7978 window.removeEventListener("keydown
", this.resetMouseScrollStateBind);
7979 window.removeEventListener("contextmenu
", this.contextMenuBind);
7980 window.removeEventListener("touchstart
", this.touchSwipeBind);
7981 window.removeEventListener("touchmove
", this.touchSwipeBind);
7982 window.removeEventListener("touchend
", this.touchSwipeBind);
7983 delete this.showControlsBind;
7984 delete this.mouseDownBind;
7985 delete this.mouseWheelBind;
7986 delete this.resetMouseScrollStateBind;
7987 delete this.contextMenuBind;
7988 delete this.touchSwipeBind;
7991 _fullscreenChange() {
7992 if (this.isFullscreen) {
7999 _addFullscreenChangeListeners() {
8000 this.fullscreenChangeBind = this._fullscreenChange.bind(this);
8001 window.addEventListener("fullscreenchange
", this.fullscreenChangeBind);
8002 window.addEventListener("mozfullscreenchange
", this.fullscreenChangeBind);
8003 window.addEventListener("webkitfullscreenchange
", this.fullscreenChangeBind);
8006 _removeFullscreenChangeListeners() {
8007 window.removeEventListener("fullscreenchange
", this.fullscreenChangeBind);
8008 window.removeEventListener("mozfullscreenchange
", this.fullscreenChangeBind);
8009 window.removeEventListener("webkitfullscreenchange
", this.fullscreenChangeBind);
8010 delete this.fullscreenChangeBind;
8015 exports.PDFPresentationMode = PDFPresentationMode;
8019 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
8023 Object.defineProperty(exports, "__esModule
", ({
8026 exports.PDFScriptingManager = void 0;
8028 var _pdfjsLib = __webpack_require__(5);
8030 var _ui_utils = __webpack_require__(4);
8032 var _pdf_rendering_queue = __webpack_require__(8);
8034 class PDFScriptingManager {
8037 sandboxBundleSrc = null,
8038 scriptingFactory = null,
8039 docPropertiesLookup = null
8041 this._pdfDocument = null;
8042 this._pdfViewer = null;
8043 this._closeCapability = null;
8044 this._destroyCapability = null;
8045 this._scripting = null;
8046 this._mouseState = Object.create(null);
8047 this._ready = false;
8048 this._eventBus = eventBus;
8049 this._sandboxBundleSrc = sandboxBundleSrc;
8050 this._scriptingFactory = scriptingFactory;
8051 this._docPropertiesLookup = docPropertiesLookup;
8054 setViewer(pdfViewer) {
8055 this._pdfViewer = pdfViewer;
8058 async setDocument(pdfDocument) {
8059 if (this._pdfDocument) {
8060 await this._destroyScripting();
8063 this._pdfDocument = pdfDocument;
8069 const [objects, calculationOrder, docActions] = await Promise.all([pdfDocument.getFieldObjects(), pdfDocument.getCalculationOrderIds(), pdfDocument.getJSActions()]);
8071 if (!objects && !docActions) {
8072 await this._destroyScripting();
8076 if (pdfDocument !== this._pdfDocument) {
8081 this._scripting = this._createScripting();
8083 console.error(`PDFScriptingManager.setDocument: "${error?.message}
".`);
8084 await this._destroyScripting();
8088 this._internalEvents.set("updatefromsandbox
", event => {
8089 if (event?.source !== window) {
8093 this._updateFromSandbox(event.detail);
8096 this._internalEvents.set("dispatcheventinsandbox
", event => {
8097 this._scripting?.dispatchEventInSandbox(event.detail);
8100 this._internalEvents.set("pagechanging
", ({
8104 if (pageNumber === previous) {
8108 this._dispatchPageClose(previous);
8110 this._dispatchPageOpen(pageNumber);
8113 this._internalEvents.set("pagerendered
", ({
8116 if (!this._pageOpenPending.has(pageNumber)) {
8120 if (pageNumber !== this._pdfViewer.currentPageNumber) {
8124 this._dispatchPageOpen(pageNumber);
8127 this._internalEvents.set("pagesdestroy
", async event => {
8128 await this._dispatchPageClose(this._pdfViewer.currentPageNumber);
8129 await this._scripting?.dispatchEventInSandbox({
8133 this._closeCapability?.resolve();
8136 this._domEvents.set("mousedown
", event => {
8137 this._mouseState.isDown = true;
8140 this._domEvents.set("mouseup
", event => {
8141 this._mouseState.isDown = false;
8144 for (const [name, listener] of this._internalEvents) {
8145 this._eventBus._on(name, listener);
8148 for (const [name, listener] of this._domEvents) {
8149 window.addEventListener(name, listener);
8153 const docProperties = await this._getDocProperties();
8155 if (pdfDocument !== this._pdfDocument) {
8159 await this._scripting.createSandbox({
8163 platform: navigator.platform,
8164 language: navigator.language
8166 docInfo: { ...docProperties,
8171 this._eventBus.dispatch("sandboxcreated
", {
8175 console.error(`PDFScriptingManager.setDocument: "${error?.message}
".`);
8176 await this._destroyScripting();
8180 await this._scripting?.dispatchEventInSandbox({
8184 await this._dispatchPageOpen(this._pdfViewer.currentPageNumber, true);
8185 Promise.resolve().then(() => {
8186 if (pdfDocument === this._pdfDocument) {
8192 async dispatchWillSave(detail) {
8193 return this._scripting?.dispatchEventInSandbox({
8199 async dispatchDidSave(detail) {
8200 return this._scripting?.dispatchEventInSandbox({
8206 async dispatchWillPrint(detail) {
8207 return this._scripting?.dispatchEventInSandbox({
8213 async dispatchDidPrint(detail) {
8214 return this._scripting?.dispatchEventInSandbox({
8221 return this._mouseState;
8224 get destroyPromise() {
8225 return this._destroyCapability?.promise || null;
8232 get _internalEvents() {
8233 return (0, _pdfjsLib.shadow)(this, "_internalEvents
", new Map());
8237 return (0, _pdfjsLib.shadow)(this, "_domEvents
", new Map());
8240 get _pageOpenPending() {
8241 return (0, _pdfjsLib.shadow)(this, "_pageOpenPending
", new Set());
8244 get _visitedPages() {
8245 return (0, _pdfjsLib.shadow)(this, "_visitedPages
", new Map());
8248 async _updateFromSandbox(detail) {
8249 const isInPresentationMode = this._pdfViewer.isInPresentationMode || this._pdfViewer.isChangingPresentationMode;
8264 console.error(value);
8268 this._pdfViewer.spreadMode = (0, _ui_utils.apiPageLayoutToSpreadMode)(value);
8272 this._pdfViewer.currentPageNumber = value + 1;
8276 await this._pdfViewer.pagesPromise;
8278 this._eventBus.dispatch("print
", {
8289 if (isInPresentationMode) {
8293 this._pdfViewer.currentScaleValue = value;
8300 if (isInPresentationMode) {
8307 delete detail.siblings;
8308 const ids = siblings ? [id, ...siblings] : [id];
8310 for (const elementId of ids) {
8311 const element = document.getElementById(elementId);
8314 element.dispatchEvent(new CustomEvent("updatefromsandbox
", {
8318 this._pdfDocument?.annotationStorage.setValue(elementId, detail);
8323 async _dispatchPageOpen(pageNumber, initialize = false) {
8324 const pdfDocument = this._pdfDocument,
8325 visitedPages = this._visitedPages;
8328 this._closeCapability = (0, _pdfjsLib.createPromiseCapability)();
8331 if (!this._closeCapability) {
8335 const pageView = this._pdfViewer.getPageView(pageNumber - 1);
8337 if (pageView?.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
8338 this._pageOpenPending.add(pageNumber);
8343 this._pageOpenPending.delete(pageNumber);
8345 const actionsPromise = (async () => {
8346 const actions = await (!visitedPages.has(pageNumber) ? pageView.pdfPage?.getJSActions() : null);
8348 if (pdfDocument !== this._pdfDocument) {
8352 await this._scripting?.dispatchEventInSandbox({
8360 visitedPages.set(pageNumber, actionsPromise);
8363 async _dispatchPageClose(pageNumber) {
8364 const pdfDocument = this._pdfDocument,
8365 visitedPages = this._visitedPages;
8367 if (!this._closeCapability) {
8371 if (this._pageOpenPending.has(pageNumber)) {
8375 const actionsPromise = visitedPages.get(pageNumber);
8377 if (!actionsPromise) {
8381 visitedPages.set(pageNumber, null);
8382 await actionsPromise;
8384 if (pdfDocument !== this._pdfDocument) {
8388 await this._scripting?.dispatchEventInSandbox({
8395 async _getDocProperties() {
8396 if (this._docPropertiesLookup) {
8397 return this._docPropertiesLookup(this._pdfDocument);
8400 throw new Error("_getDocProperties
: Unable to lookup properties
.");
8403 _createScripting() {
8404 this._destroyCapability = (0, _pdfjsLib.createPromiseCapability)();
8406 if (this._scripting) {
8407 throw new Error("_createScripting
: Scripting already exists
.");
8410 if (this._scriptingFactory) {
8411 return this._scriptingFactory.createScripting({
8412 sandboxBundleSrc: this._sandboxBundleSrc
8416 throw new Error("_createScripting
: Cannot create scripting
.");
8419 async _destroyScripting() {
8420 if (!this._scripting) {
8421 this._pdfDocument = null;
8422 this._destroyCapability?.resolve();
8426 if (this._closeCapability) {
8427 await Promise.race([this._closeCapability.promise, new Promise(resolve => {
8428 setTimeout(resolve, 1000);
8429 })]).catch(reason => {});
8430 this._closeCapability = null;
8433 this._pdfDocument = null;
8436 await this._scripting.destroySandbox();
8439 for (const [name, listener] of this._internalEvents) {
8440 this._eventBus._off(name, listener);
8443 this._internalEvents.clear();
8445 for (const [name, listener] of this._domEvents) {
8446 window.removeEventListener(name, listener);
8449 this._domEvents.clear();
8451 this._pageOpenPending.clear();
8453 this._visitedPages.clear();
8455 this._scripting = null;
8456 delete this._mouseState.isDown;
8457 this._ready = false;
8458 this._destroyCapability?.resolve();
8463 exports.PDFScriptingManager = PDFScriptingManager;
8467 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
8471 Object.defineProperty(exports, "__esModule
", ({
8474 exports.PDFSidebar = void 0;
8476 var _ui_utils = __webpack_require__(4);
8478 var _pdf_rendering_queue = __webpack_require__(8);
8480 const UI_NOTIFICATION_CLASS = "pdfSidebarNotification
";
8490 this.isOpen = false;
8491 this.active = _ui_utils.SidebarView.THUMBS;
8492 this.isInitialViewSet = false;
8493 this.onToggled = null;
8494 this.pdfViewer = pdfViewer;
8495 this.pdfThumbnailViewer = pdfThumbnailViewer;
8496 this.outerContainer = elements.outerContainer;
8497 this.viewerContainer = elements.viewerContainer;
8498 this.toggleButton = elements.toggleButton;
8499 this.thumbnailButton = elements.thumbnailButton;
8500 this.outlineButton = elements.outlineButton;
8501 this.attachmentsButton = elements.attachmentsButton;
8502 this.layersButton = elements.layersButton;
8503 this.thumbnailView = elements.thumbnailView;
8504 this.outlineView = elements.outlineView;
8505 this.attachmentsView = elements.attachmentsView;
8506 this.layersView = elements.layersView;
8507 this._outlineOptionsContainer = elements.outlineOptionsContainer;
8508 this._currentOutlineItemButton = elements.currentOutlineItemButton;
8509 this.eventBus = eventBus;
8512 this._addEventListeners();
8516 this.isInitialViewSet = false;
8518 this._hideUINotification(true);
8520 this.switchView(_ui_utils.SidebarView.THUMBS);
8521 this.outlineButton.disabled = false;
8522 this.attachmentsButton.disabled = false;
8523 this.layersButton.disabled = false;
8524 this._currentOutlineItemButton.disabled = true;
8528 return this.isOpen ? this.active : _ui_utils.SidebarView.NONE;
8531 get isThumbnailViewVisible() {
8532 return this.isOpen && this.active === _ui_utils.SidebarView.THUMBS;
8535 get isOutlineViewVisible() {
8536 return this.isOpen && this.active === _ui_utils.SidebarView.OUTLINE;
8539 get isAttachmentsViewVisible() {
8540 return this.isOpen && this.active === _ui_utils.SidebarView.ATTACHMENTS;
8543 get isLayersViewVisible() {
8544 return this.isOpen && this.active === _ui_utils.SidebarView.LAYERS;
8547 setInitialView(view = _ui_utils.SidebarView.NONE) {
8548 if (this.isInitialViewSet) {
8552 this.isInitialViewSet = true;
8554 if (view === _ui_utils.SidebarView.NONE || view === _ui_utils.SidebarView.UNKNOWN) {
8555 this._dispatchEvent();
8560 if (!this._switchView(view, true)) {
8561 this._dispatchEvent();
8565 switchView(view, forceOpen = false) {
8566 this._switchView(view, forceOpen);
8569 _switchView(view, forceOpen = false) {
8570 const isViewChanged = view !== this.active;
8571 let shouldForceRendering = false;
8574 case _ui_utils.SidebarView.NONE:
8582 case _ui_utils.SidebarView.THUMBS:
8583 if (this.isOpen && isViewChanged) {
8584 shouldForceRendering = true;
8589 case _ui_utils.SidebarView.OUTLINE:
8590 if (this.outlineButton.disabled) {
8596 case _ui_utils.SidebarView.ATTACHMENTS:
8597 if (this.attachmentsButton.disabled) {
8603 case _ui_utils.SidebarView.LAYERS:
8604 if (this.layersButton.disabled) {
8611 console.error(`PDFSidebar._switchView: "${view}
" is not a valid view.`);
8616 this.thumbnailButton.classList.toggle("toggled
", view === _ui_utils.SidebarView.THUMBS);
8617 this.outlineButton.classList.toggle("toggled
", view === _ui_utils.SidebarView.OUTLINE);
8618 this.attachmentsButton.classList.toggle("toggled
", view === _ui_utils.SidebarView.ATTACHMENTS);
8619 this.layersButton.classList.toggle("toggled
", view === _ui_utils.SidebarView.LAYERS);
8620 this.thumbnailView.classList.toggle("hidden
", view !== _ui_utils.SidebarView.THUMBS);
8621 this.outlineView.classList.toggle("hidden
", view !== _ui_utils.SidebarView.OUTLINE);
8622 this.attachmentsView.classList.toggle("hidden
", view !== _ui_utils.SidebarView.ATTACHMENTS);
8623 this.layersView.classList.toggle("hidden
", view !== _ui_utils.SidebarView.LAYERS);
8625 this._outlineOptionsContainer.classList.toggle("hidden
", view !== _ui_utils.SidebarView.OUTLINE);
8627 if (forceOpen && !this.isOpen) {
8632 if (shouldForceRendering) {
8633 this._updateThumbnailViewer();
8635 this._forceRendering();
8638 if (isViewChanged) {
8639 this._dispatchEvent();
8642 return isViewChanged;
8651 this.toggleButton.classList.add("toggled
");
8652 this.toggleButton.setAttribute("aria
-expanded
", "true");
8653 this.outerContainer.classList.add("sidebarMoving
", "sidebarOpen
");
8655 if (this.active === _ui_utils.SidebarView.THUMBS) {
8656 this._updateThumbnailViewer();
8659 this._forceRendering();
8661 this._dispatchEvent();
8663 this._hideUINotification();
8671 this.isOpen = false;
8672 this.toggleButton.classList.remove("toggled
");
8673 this.toggleButton.setAttribute("aria
-expanded
", "false");
8674 this.outerContainer.classList.add("sidebarMoving
");
8675 this.outerContainer.classList.remove("sidebarOpen
");
8677 this._forceRendering();
8679 this._dispatchEvent();
8691 this.eventBus.dispatch("sidebarviewchanged
", {
8693 view: this.visibleView
8698 if (this.onToggled) {
8701 this.pdfViewer.forceRendering();
8702 this.pdfThumbnailViewer.forceRendering();
8706 _updateThumbnailViewer() {
8711 const pagesCount = pdfViewer.pagesCount;
8713 for (let pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
8714 const pageView = pdfViewer.getPageView(pageIndex);
8716 if (pageView?.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
8717 const thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
8718 thumbnailView.setImage(pageView);
8722 pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
8725 _showUINotification() {
8726 this.l10n.get("toggle_sidebar_notification2
.title
").then(msg => {
8727 this.toggleButton.title = msg;
8731 this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
8735 _hideUINotification(reset = false) {
8736 if (this.isOpen || reset) {
8737 this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
8741 this.l10n.get("toggle_sidebar
.title
").then(msg => {
8742 this.toggleButton.title = msg;
8747 _addEventListeners() {
8748 this.viewerContainer.addEventListener("transitionend
", evt => {
8749 if (evt.target === this.viewerContainer) {
8750 this.outerContainer.classList.remove("sidebarMoving
");
8753 this.toggleButton.addEventListener("click
", () => {
8756 this.thumbnailButton.addEventListener("click
", () => {
8757 this.switchView(_ui_utils.SidebarView.THUMBS);
8759 this.outlineButton.addEventListener("click
", () => {
8760 this.switchView(_ui_utils.SidebarView.OUTLINE);
8762 this.outlineButton.addEventListener("dblclick
", () => {
8763 this.eventBus.dispatch("toggleoutlinetree
", {
8767 this.attachmentsButton.addEventListener("click
", () => {
8768 this.switchView(_ui_utils.SidebarView.ATTACHMENTS);
8770 this.layersButton.addEventListener("click
", () => {
8771 this.switchView(_ui_utils.SidebarView.LAYERS);
8773 this.layersButton.addEventListener("dblclick
", () => {
8774 this.eventBus.dispatch("resetlayers
", {
8779 this._currentOutlineItemButton.addEventListener("click
", () => {
8780 this.eventBus.dispatch("currentoutlineitem
", {
8785 const onTreeLoaded = (count, button, view) => {
8786 button.disabled = !count;
8789 this._showUINotification();
8790 } else if (this.active === view) {
8791 this.switchView(_ui_utils.SidebarView.THUMBS);
8795 this.eventBus._on("outlineloaded
", evt => {
8796 onTreeLoaded(evt.outlineCount, this.outlineButton, _ui_utils.SidebarView.OUTLINE);
8797 evt.currentOutlineItemPromise.then(enabled => {
8798 if (!this.isInitialViewSet) {
8802 this._currentOutlineItemButton.disabled = !enabled;
8806 this.eventBus._on("attachmentsloaded
", evt => {
8807 onTreeLoaded(evt.attachmentsCount, this.attachmentsButton, _ui_utils.SidebarView.ATTACHMENTS);
8810 this.eventBus._on("layersloaded
", evt => {
8811 onTreeLoaded(evt.layersCount, this.layersButton, _ui_utils.SidebarView.LAYERS);
8814 this.eventBus._on("presentationmodechanged
", evt => {
8815 if (evt.state === _ui_utils.PresentationModeState.NORMAL && this.isThumbnailViewVisible) {
8816 this._updateThumbnailViewer();
8823 exports.PDFSidebar = PDFSidebar;
8827 /***/ ((__unused_webpack_module, exports) => {
8831 Object.defineProperty(exports, "__esModule
", ({
8834 exports.PDFSidebarResizer = void 0;
8835 const SIDEBAR_WIDTH_VAR = "--sidebar
-width
";
8836 const SIDEBAR_MIN_WIDTH = 200;
8837 const SIDEBAR_RESIZING_CLASS = "sidebarResizing
";
8839 class PDFSidebarResizer {
8840 constructor(options, eventBus, l10n) {
8842 this.sidebarOpen = false;
8843 this.doc = document.documentElement;
8845 this._outerContainerWidth = null;
8846 this._boundEvents = Object.create(null);
8847 this.outerContainer = options.outerContainer;
8848 this.resizer = options.resizer;
8849 this.eventBus = eventBus;
8850 l10n.getDirection().then(dir => {
8851 this.isRTL = dir === "rtl
";
8854 this._addEventListeners();
8857 get outerContainerWidth() {
8858 return this._outerContainerWidth || (this._outerContainerWidth = this.outerContainer.clientWidth);
8861 _updateWidth(width = 0) {
8862 const maxWidth = Math.floor(this.outerContainerWidth / 2);
8864 if (width > maxWidth) {
8868 if (width < SIDEBAR_MIN_WIDTH) {
8869 width = SIDEBAR_MIN_WIDTH;
8872 if (width === this._width) {
8876 this._width = width;
8877 this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, `${width}px`);
8882 let width = evt.clientX;
8885 width = this.outerContainerWidth - width;
8888 this._updateWidth(width);
8892 this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
8893 this.eventBus.dispatch("resize
", {
8896 const _boundEvents = this._boundEvents;
8897 window.removeEventListener("mousemove
", _boundEvents.mouseMove);
8898 window.removeEventListener("mouseup
", _boundEvents.mouseUp);
8901 _addEventListeners() {
8902 const _boundEvents = this._boundEvents;
8903 _boundEvents.mouseMove = this._mouseMove.bind(this);
8904 _boundEvents.mouseUp = this._mouseUp.bind(this);
8905 this.resizer.addEventListener("mousedown
", evt => {
8906 if (evt.button !== 0) {
8910 this.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
8911 window.addEventListener("mousemove
", _boundEvents.mouseMove);
8912 window.addEventListener("mouseup
", _boundEvents.mouseUp);
8915 this.eventBus._on("sidebarviewchanged
", evt => {
8916 this.sidebarOpen = !!evt?.view;
8919 this.eventBus._on("resize
", evt => {
8920 if (evt?.source !== window) {
8924 this._outerContainerWidth = null;
8930 if (!this.sidebarOpen) {
8931 this._updateWidth(this._width);
8936 this.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
8938 const updated = this._updateWidth(this._width);
8940 Promise.resolve().then(() => {
8941 this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
8944 this.eventBus.dispatch("resize
", {
8954 exports.PDFSidebarResizer = PDFSidebarResizer;
8958 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
8962 Object.defineProperty(exports, "__esModule
", ({
8965 exports.PDFThumbnailViewer = void 0;
8967 var _ui_utils = __webpack_require__(4);
8969 var _pdf_thumbnail_view = __webpack_require__(26);
8971 var _pdf_rendering_queue = __webpack_require__(8);
8973 const THUMBNAIL_SCROLL_MARGIN = -19;
8974 const THUMBNAIL_SELECTED_CLASS = "selected
";
8976 class PDFThumbnailViewer {
8984 this.container = container;
8985 this.linkService = linkService;
8986 this.renderingQueue = renderingQueue;
8988 this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
8992 eventBus._on("optionalcontentconfigchanged
", () => {
8993 this._setImageDisabled = true;
8998 this.renderingQueue.renderHighestPriority();
9001 getThumbnail(index) {
9002 return this._thumbnails[index];
9005 _getVisibleThumbs() {
9006 return (0, _ui_utils.getVisibleElements)({
9007 scrollEl: this.container,
9008 views: this._thumbnails
9012 scrollThumbnailIntoView(pageNumber) {
9013 if (!this.pdfDocument) {
9017 const thumbnailView = this._thumbnails[pageNumber - 1];
9019 if (!thumbnailView) {
9020 console.error('scrollThumbnailIntoView: Invalid "pageNumber
" parameter.');
9024 if (pageNumber !== this._currentPageNumber) {
9025 const prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
9026 prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
9027 thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
9030 const visibleThumbs = this._getVisibleThumbs();
9032 const numVisibleThumbs = visibleThumbs.views.length;
9034 if (numVisibleThumbs > 0) {
9035 const first = visibleThumbs.first.id;
9036 const last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
9037 let shouldScroll = false;
9039 if (pageNumber <= first || pageNumber >= last) {
9040 shouldScroll = true;
9042 visibleThumbs.views.some(function (view) {
9043 if (view.id !== pageNumber) {
9047 shouldScroll = view.percent < 100;
9053 (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
9054 top: THUMBNAIL_SCROLL_MARGIN
9059 this._currentPageNumber = pageNumber;
9062 get pagesRotation() {
9063 return this._pagesRotation;
9066 set pagesRotation(rotation) {
9067 if (!(0, _ui_utils.isValidRotation)(rotation)) {
9068 throw new Error("Invalid thumbnails rotation angle
.");
9071 if (!this.pdfDocument) {
9075 if (this._pagesRotation === rotation) {
9079 this._pagesRotation = rotation;
9081 for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
9082 this._thumbnails[i].update(rotation);
9087 for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
9088 if (this._thumbnails[i] && this._thumbnails[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
9089 this._thumbnails[i].reset();
9093 _pdf_thumbnail_view.TempImageFactory.destroyCanvas();
9097 this._thumbnails = [];
9098 this._currentPageNumber = 1;
9099 this._pageLabels = null;
9100 this._pagesRotation = 0;
9101 this._optionalContentConfigPromise = null;
9102 this._pagesRequests = new WeakMap();
9103 this._setImageDisabled = false;
9104 this.container.textContent = "";
9107 setDocument(pdfDocument) {
9108 if (this.pdfDocument) {
9109 this._cancelRendering();
9114 this.pdfDocument = pdfDocument;
9120 const firstPagePromise = pdfDocument.getPage(1);
9121 const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
9122 firstPagePromise.then(firstPdfPage => {
9123 this._optionalContentConfigPromise = optionalContentConfigPromise;
9124 const pagesCount = pdfDocument.numPages;
9125 const viewport = firstPdfPage.getViewport({
9129 const checkSetImageDisabled = () => {
9130 return this._setImageDisabled;
9133 for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
9134 const thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
9135 container: this.container,
9137 defaultViewport: viewport.clone(),
9138 optionalContentConfigPromise,
9139 linkService: this.linkService,
9140 renderingQueue: this.renderingQueue,
9141 checkSetImageDisabled,
9145 this._thumbnails.push(thumbnail);
9148 const firstThumbnailView = this._thumbnails[0];
9150 if (firstThumbnailView) {
9151 firstThumbnailView.setPdfPage(firstPdfPage);
9154 const thumbnailView = this._thumbnails[this._currentPageNumber - 1];
9155 thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
9156 }).catch(reason => {
9157 console.error("Unable to initialize thumbnail viewer
", reason);
9161 _cancelRendering() {
9162 for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
9163 if (this._thumbnails[i]) {
9164 this._thumbnails[i].cancelRendering();
9169 setPageLabels(labels) {
9170 if (!this.pdfDocument) {
9175 this._pageLabels = null;
9176 } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
9177 this._pageLabels = null;
9178 console.error("PDFThumbnailViewer_setPageLabels
: Invalid page labels
.");
9180 this._pageLabels = labels;
9183 for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
9184 this._thumbnails[i].setPageLabel(this._pageLabels?.[i] ?? null);
9188 _ensurePdfPageLoaded(thumbView) {
9189 if (thumbView.pdfPage) {
9190 return Promise.resolve(thumbView.pdfPage);
9193 if (this._pagesRequests.has(thumbView)) {
9194 return this._pagesRequests.get(thumbView);
9197 const promise = this.pdfDocument.getPage(thumbView.id).then(pdfPage => {
9198 if (!thumbView.pdfPage) {
9199 thumbView.setPdfPage(pdfPage);
9202 this._pagesRequests.delete(thumbView);
9205 }).catch(reason => {
9206 console.error("Unable to
get page
for thumb view
", reason);
9208 this._pagesRequests.delete(thumbView);
9211 this._pagesRequests.set(thumbView, promise);
9217 const visibleThumbs = this._getVisibleThumbs();
9219 const thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
9222 this._ensurePdfPageLoaded(thumbView).then(() => {
9223 this.renderingQueue.renderView(thumbView);
9234 exports.PDFThumbnailViewer = PDFThumbnailViewer;
9238 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
9242 Object.defineProperty(exports, "__esModule
", ({
9245 exports.TempImageFactory = exports.PDFThumbnailView = void 0;
9247 var _ui_utils = __webpack_require__(4);
9249 var _pdfjsLib = __webpack_require__(5);
9251 var _pdf_rendering_queue = __webpack_require__(8);
9253 const DRAW_UPSCALE_FACTOR = 2;
9254 const MAX_NUM_SCALING_STEPS = 3;
9255 const THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
9256 const THUMBNAIL_WIDTH = 98;
9258 const TempImageFactory = function TempImageFactoryClosure() {
9259 let tempCanvasCache = null;
9261 getCanvas(width, height) {
9262 let tempCanvas = tempCanvasCache;
9265 tempCanvas = document.createElement("canvas
");
9266 tempCanvasCache = tempCanvas;
9269 tempCanvas.width = width;
9270 tempCanvas.height = height;
9271 tempCanvas.mozOpaque = true;
9272 const ctx = tempCanvas.getContext("2d
", {
9276 ctx.fillStyle = "rgb(255, 255, 255)";
9277 ctx.fillRect(0, 0, width, height);
9279 return [tempCanvas, tempCanvas.getContext("2d
")];
9283 const tempCanvas = tempCanvasCache;
9286 tempCanvas.width = 0;
9287 tempCanvas.height = 0;
9290 tempCanvasCache = null;
9296 exports.TempImageFactory = TempImageFactory;
9298 class PDFThumbnailView {
9303 optionalContentConfigPromise,
9306 checkSetImageDisabled,
9310 this.renderingId = "thumbnail
" + id;
9311 this.pageLabel = null;
9312 this.pdfPage = null;
9314 this.viewport = defaultViewport;
9315 this.pdfPageRotate = defaultViewport.rotation;
9316 this._optionalContentConfigPromise = optionalContentConfigPromise || null;
9317 this.linkService = linkService;
9318 this.renderingQueue = renderingQueue;
9319 this.renderTask = null;
9320 this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
9323 this._checkSetImageDisabled = checkSetImageDisabled || function () {
9327 const pageWidth = this.viewport.width,
9328 pageHeight = this.viewport.height,
9329 pageRatio = pageWidth / pageHeight;
9330 this.canvasWidth = THUMBNAIL_WIDTH;
9331 this.canvasHeight = this.canvasWidth / pageRatio | 0;
9332 this.scale = this.canvasWidth / pageWidth;
9334 const anchor = document.createElement("a
");
9335 anchor.href = linkService.getAnchorUrl("#page
=" + id);
9337 this._thumbPageTitle.then(msg => {
9341 anchor.onclick = function () {
9342 linkService.goToPage(id);
9346 this.anchor = anchor;
9347 const div = document.createElement("div
");
9348 div.className = "thumbnail
";
9349 div.setAttribute("data
-page
-number
", this.id);
9351 const ring = document.createElement("div
");
9352 ring.className = "thumbnailSelectionRing
";
9353 const borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
9354 ring.style.width = this.canvasWidth + borderAdjustment + "px
";
9355 ring.style.height = this.canvasHeight + borderAdjustment + "px
";
9357 div.appendChild(ring);
9358 anchor.appendChild(div);
9359 container.appendChild(anchor);
9362 setPdfPage(pdfPage) {
9363 this.pdfPage = pdfPage;
9364 this.pdfPageRotate = pdfPage.rotate;
9365 const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
9366 this.viewport = pdfPage.getViewport({
9368 rotation: totalRotation
9374 this.cancelRendering();
9375 this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
9376 const pageWidth = this.viewport.width,
9377 pageHeight = this.viewport.height,
9378 pageRatio = pageWidth / pageHeight;
9379 this.canvasHeight = this.canvasWidth / pageRatio | 0;
9380 this.scale = this.canvasWidth / pageWidth;
9381 this.div.removeAttribute("data
-loaded
");
9382 const ring = this.ring;
9383 ring.textContent = "";
9384 const borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
9385 ring.style.width = this.canvasWidth + borderAdjustment + "px
";
9386 ring.style.height = this.canvasHeight + borderAdjustment + "px
";
9389 this.canvas.width = 0;
9390 this.canvas.height = 0;
9395 this.image.removeAttribute("src
");
9401 if (typeof rotation !== "undefined") {
9402 this.rotation = rotation;
9405 const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
9406 this.viewport = this.viewport.clone({
9408 rotation: totalRotation
9414 if (this.renderTask) {
9415 this.renderTask.cancel();
9416 this.renderTask = null;
9422 _getPageDrawContext(upscaleFactor = 1) {
9423 const canvas = document.createElement("canvas
");
9424 canvas.mozOpaque = true;
9425 const ctx = canvas.getContext("2d
", {
9428 const outputScale = (0, _ui_utils.getOutputScale)(ctx);
9429 canvas.width = upscaleFactor * this.canvasWidth * outputScale.sx | 0;
9430 canvas.height = upscaleFactor * this.canvasHeight * outputScale.sy | 0;
9431 const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
9439 _convertCanvasToImage(canvas) {
9440 if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
9441 throw new Error("_convertCanvasToImage
: Rendering has not finished
.");
9444 const reducedCanvas = this._reduceImage(canvas);
9446 const image = document.createElement("img
");
9447 image.className = "thumbnailImage
";
9449 this._thumbPageCanvas.then(msg => {
9450 image.setAttribute("aria
-label
", msg);
9453 image.style.width = this.canvasWidth + "px
";
9454 image.style.height = this.canvasHeight + "px
";
9455 image.src = reducedCanvas.toDataURL();
9457 this.div.setAttribute("data
-loaded
", true);
9458 this.ring.appendChild(image);
9459 reducedCanvas.width = 0;
9460 reducedCanvas.height = 0;
9464 if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
9465 console.error("Must be
in new state before drawing
");
9466 return Promise.resolve(undefined);
9474 this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
9475 return Promise.reject(new Error("pdfPage is not loaded
"));
9478 this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
9480 const finishRenderTask = async (error = null) => {
9481 if (renderTask === this.renderTask) {
9482 this.renderTask = null;
9485 if (error instanceof _pdfjsLib.RenderingCancelledException) {
9489 this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
9491 this._convertCanvasToImage(canvas);
9502 } = this._getPageDrawContext(DRAW_UPSCALE_FACTOR);
9504 const drawViewport = this.viewport.clone({
9505 scale: DRAW_UPSCALE_FACTOR * this.scale
9508 const renderContinueCallback = cont => {
9509 if (!this.renderingQueue.isHighestPriority(this)) {
9510 this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
9512 this.resume = () => {
9513 this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
9523 const renderContext = {
9526 viewport: drawViewport,
9527 optionalContentConfigPromise: this._optionalContentConfigPromise
9529 const renderTask = this.renderTask = pdfPage.render(renderContext);
9530 renderTask.onContinue = renderContinueCallback;
9531 const resultPromise = renderTask.promise.then(function () {
9532 return finishRenderTask(null);
9533 }, function (error) {
9534 return finishRenderTask(error);
9536 resultPromise.finally(() => {
9539 const pageCached = this.linkService.isPageCached(this.id);
9542 this.pdfPage?.cleanup();
9545 return resultPromise;
9548 setImage(pageView) {
9549 if (this._checkSetImageDisabled()) {
9553 if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
9566 if (!this.pdfPage) {
9567 this.setPdfPage(pdfPage);
9570 this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
9572 this._convertCanvasToImage(canvas);
9579 } = this._getPageDrawContext();
9581 if (img.width <= 2 * canvas.width) {
9582 ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
9586 let reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
9587 let reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
9588 const [reducedImage, reducedImageCtx] = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
9590 while (reducedWidth > img.width || reducedHeight > img.height) {
9592 reducedHeight >>= 1;
9595 reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
9597 while (reducedWidth > 2 * canvas.width) {
9598 reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
9600 reducedHeight >>= 1;
9603 ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
9607 get _thumbPageTitle() {
9608 return this.l10n.get("thumb_page_title
", {
9609 page: this.pageLabel ?? this.id
9613 get _thumbPageCanvas() {
9614 return this.l10n.get("thumb_page_canvas
", {
9615 page: this.pageLabel ?? this.id
9619 setPageLabel(label) {
9620 this.pageLabel = typeof label === "string
" ? label : null;
9622 this._thumbPageTitle.then(msg => {
9623 this.anchor.title = msg;
9626 if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
9630 this._thumbPageCanvas.then(msg => {
9631 this.image?.setAttribute("aria
-label
", msg);
9637 exports.PDFThumbnailView = PDFThumbnailView;
9641 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
9645 Object.defineProperty(exports, "__esModule
", ({
9648 exports.PDFViewer = void 0;
9650 var _ui_utils = __webpack_require__(4);
9652 var _base_viewer = __webpack_require__(28);
9654 var _pdfjsLib = __webpack_require__(5);
9656 class PDFViewer extends _base_viewer.BaseViewer {
9657 get _viewerElement() {
9658 return (0, _pdfjsLib.shadow)(this, "_viewerElement
", this.viewer);
9666 if (!pageSpot && !this.isInPresentationMode) {
9667 const left = pageDiv.offsetLeft + pageDiv.clientLeft;
9668 const right = left + pageDiv.clientWidth;
9674 if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
9682 super._scrollIntoView({
9689 _getVisiblePages() {
9690 if (this.isInPresentationMode) {
9691 return this._getCurrentVisiblePage();
9694 return super._getVisiblePages();
9697 _updateHelper(visiblePages) {
9698 if (this.isInPresentationMode) {
9702 let currentId = this._currentPageNumber;
9703 let stillFullyVisible = false;
9705 for (const page of visiblePages) {
9706 if (page.percent < 100) {
9710 if (page.id === currentId && this._scrollMode === _ui_utils.ScrollMode.VERTICAL && this._spreadMode === _ui_utils.SpreadMode.NONE) {
9711 stillFullyVisible = true;
9716 if (!stillFullyVisible) {
9717 currentId = visiblePages[0].id;
9720 this._setCurrentPageNumber(currentId);
9725 exports.PDFViewer = PDFViewer;
9729 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
9733 Object.defineProperty(exports, "__esModule
", ({
9736 exports.BaseViewer = void 0;
9738 var _pdfjsLib = __webpack_require__(5);
9740 var _ui_utils = __webpack_require__(4);
9742 var _pdf_rendering_queue = __webpack_require__(8);
9744 var _annotation_layer_builder = __webpack_require__(29);
9746 var _l10n_utils = __webpack_require__(30);
9748 var _pdf_page_view = __webpack_require__(31);
9750 var _pdf_link_service = __webpack_require__(19);
9752 var _struct_tree_layer_builder = __webpack_require__(32);
9754 var _text_layer_builder = __webpack_require__(33);
9756 var _xfa_layer_builder = __webpack_require__(34);
9758 const DEFAULT_CACHE_SIZE = 10;
9760 function PDFPageViewBuffer(size) {
9763 this.push = function (view) {
9764 const i = data.indexOf(view);
9772 if (data.length > size) {
9773 data.shift().destroy();
9777 this.resize = function (newSize, pagesToKeep) {
9781 const pageIdsToKeep = new Set();
9783 for (let i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
9784 pageIdsToKeep.add(pagesToKeep[i].id);
9787 (0, _ui_utils.moveToEndOfArray)(data, function (page) {
9788 return pageIdsToKeep.has(page.id);
9792 while (data.length > size) {
9793 data.shift().destroy();
9797 this.has = function (view) {
9798 return data.includes(view);
9802 function isSameScale(oldScale, newScale) {
9803 if (newScale === oldScale) {
9807 if (Math.abs(newScale - oldScale) < 1e-15) {
9815 constructor(options) {
9816 if (this.constructor === BaseViewer) {
9817 throw new Error("Cannot initialize BaseViewer
.");
9820 const viewerVersion = '2.10.377';
9822 if (_pdfjsLib.version !== viewerVersion) {
9823 throw new Error(`The API version "${_pdfjsLib.version}
" does not match the Viewer version "${viewerVersion}
".`);
9826 this._name = this.constructor.name;
9827 this.container = options.container;
9828 this.viewer = options.viewer || options.container.firstElementChild;
9830 if (!(this.container?.tagName.toUpperCase() === "DIV
" && this.viewer?.tagName.toUpperCase() === "DIV
")) {
9831 throw new Error("Invalid
`container` and
/or
`viewer` option
.");
9834 if (this.container.offsetParent && getComputedStyle(this.container).position !== "absolute
") {
9835 throw new Error("The
`container` must be absolutely positioned
.");
9838 this.eventBus = options.eventBus;
9839 this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
9840 this.downloadManager = options.downloadManager || null;
9841 this.findController = options.findController || null;
9842 this._scriptingManager = options.scriptingManager || null;
9843 this.removePageBorders = options.removePageBorders || false;
9844 this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
9845 this.imageResourcesPath = options.imageResourcesPath || "";
9846 this.renderInteractiveForms = options.renderInteractiveForms !== false;
9847 this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
9848 this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
9849 this.useOnlyCssZoom = options.useOnlyCssZoom || false;
9850 this.maxCanvasPixels = options.maxCanvasPixels;
9851 this.l10n = options.l10n || _l10n_utils.NullL10n;
9852 this.enableScripting = options.enableScripting === true && !!this._scriptingManager;
9853 this.defaultRenderingQueue = !options.renderingQueue;
9855 if (this.defaultRenderingQueue) {
9856 this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
9857 this.renderingQueue.setViewer(this);
9859 this.renderingQueue = options.renderingQueue;
9862 this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
9863 this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
9864 this._onBeforeDraw = this._onAfterDraw = null;
9868 if (this.removePageBorders) {
9869 this.viewer.classList.add("removePageBorders
");
9872 Promise.resolve().then(() => {
9873 this.eventBus.dispatch("baseviewerinit
", {
9880 return this._pages.length;
9883 getPageView(index) {
9884 return this._pages[index];
9887 get pageViewsReady() {
9888 if (!this._pagesCapability.settled) {
9892 return this._pages.every(function (pageView) {
9893 return pageView?.pdfPage;
9897 get currentPageNumber() {
9898 return this._currentPageNumber;
9901 set currentPageNumber(val) {
9902 if (!Number.isInteger(val)) {
9903 throw new Error("Invalid page number
.");
9906 if (!this.pdfDocument) {
9910 if (!this._setCurrentPageNumber(val, true)) {
9911 console.error(`${this._name}.currentPageNumber: "${val}
" is not a valid page.`);
9915 _setCurrentPageNumber(val, resetCurrentPageView = false) {
9916 if (this._currentPageNumber === val) {
9917 if (resetCurrentPageView) {
9918 this._resetCurrentPageView();
9924 if (!(0 < val && val <= this.pagesCount)) {
9928 const previous = this._currentPageNumber;
9929 this._currentPageNumber = val;
9930 this.eventBus.dispatch("pagechanging
", {
9933 pageLabel: this._pageLabels?.[val - 1] ?? null,
9937 if (resetCurrentPageView) {
9938 this._resetCurrentPageView();
9944 get currentPageLabel() {
9945 return this._pageLabels?.[this._currentPageNumber - 1] ?? null;
9948 set currentPageLabel(val) {
9949 if (!this.pdfDocument) {
9955 if (this._pageLabels) {
9956 const i = this._pageLabels.indexOf(val);
9963 if (!this._setCurrentPageNumber(page, true)) {
9964 console.error(`${this._name}.currentPageLabel: "${val}
" is not a valid page.`);
9968 get currentScale() {
9969 return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
9972 set currentScale(val) {
9974 throw new Error("Invalid numeric scale
.");
9977 if (!this.pdfDocument) {
9981 this._setScale(val, false);
9984 get currentScaleValue() {
9985 return this._currentScaleValue;
9988 set currentScaleValue(val) {
9989 if (!this.pdfDocument) {
9993 this._setScale(val, false);
9996 get pagesRotation() {
9997 return this._pagesRotation;
10000 set pagesRotation(rotation) {
10001 if (!(0, _ui_utils.isValidRotation)(rotation)) {
10002 throw new Error("Invalid pages rotation angle
.");
10005 if (!this.pdfDocument) {
10011 if (rotation < 0) {
10015 if (this._pagesRotation === rotation) {
10019 this._pagesRotation = rotation;
10020 const pageNumber = this._currentPageNumber;
10022 for (let i = 0, ii = this._pages.length; i < ii; i++) {
10023 const pageView = this._pages[i];
10024 pageView.update(pageView.scale, rotation);
10027 if (this._currentScaleValue) {
10028 this._setScale(this._currentScaleValue, true);
10031 this.eventBus.dispatch("rotationchanging
", {
10033 pagesRotation: rotation,
10037 if (this.defaultRenderingQueue) {
10042 get firstPagePromise() {
10043 return this.pdfDocument ? this._firstPageCapability.promise : null;
10046 get onePageRendered() {
10047 return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
10050 get pagesPromise() {
10051 return this.pdfDocument ? this._pagesCapability.promise : null;
10054 get _viewerElement() {
10055 throw new Error("Not implemented
: _viewerElement
");
10058 _onePageRenderedOrForceFetch() {
10059 if (!this.container.offsetParent || this._getVisiblePages().views.length === 0) {
10060 return Promise.resolve();
10063 return this._onePageRenderedCapability.promise;
10066 setDocument(pdfDocument) {
10067 if (this.pdfDocument) {
10068 this.eventBus.dispatch("pagesdestroy
", {
10072 this._cancelRendering();
10076 if (this.findController) {
10077 this.findController.setDocument(null);
10080 if (this._scriptingManager) {
10081 this._scriptingManager.setDocument(null);
10085 this.pdfDocument = pdfDocument;
10087 if (!pdfDocument) {
10091 const isPureXfa = pdfDocument.isPureXfa;
10092 const pagesCount = pdfDocument.numPages;
10093 const firstPagePromise = pdfDocument.getPage(1);
10094 const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
10096 this._pagesCapability.promise.then(() => {
10097 this.eventBus.dispatch("pagesloaded
", {
10103 this._onBeforeDraw = evt => {
10104 const pageView = this._pages[evt.pageNumber - 1];
10110 this._buffer.push(pageView);
10113 this.eventBus._on("pagerender
", this._onBeforeDraw);
10115 this._onAfterDraw = evt => {
10116 if (evt.cssTransform || this._onePageRenderedCapability.settled) {
10120 this._onePageRenderedCapability.resolve();
10122 this.eventBus._off("pagerendered
", this._onAfterDraw);
10124 this._onAfterDraw = null;
10127 this.eventBus._on("pagerendered
", this._onAfterDraw);
10129 firstPagePromise.then(firstPdfPage => {
10130 this._firstPageCapability.resolve(firstPdfPage);
10132 this._optionalContentConfigPromise = optionalContentConfigPromise;
10133 const scale = this.currentScale;
10134 const viewport = firstPdfPage.getViewport({
10135 scale: scale * _ui_utils.CSS_UNITS
10137 const textLayerFactory = this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE ? this : null;
10138 const xfaLayerFactory = isPureXfa ? this : null;
10140 for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
10141 const pageView = new _pdf_page_view.PDFPageView({
10142 container: this._viewerElement,
10143 eventBus: this.eventBus,
10146 defaultViewport: viewport.clone(),
10147 optionalContentConfigPromise,
10148 renderingQueue: this.renderingQueue,
10150 textLayerMode: this.textLayerMode,
10151 annotationLayerFactory: this,
10153 structTreeLayerFactory: this,
10154 imageResourcesPath: this.imageResourcesPath,
10155 renderInteractiveForms: this.renderInteractiveForms,
10156 renderer: this.renderer,
10157 useOnlyCssZoom: this.useOnlyCssZoom,
10158 maxCanvasPixels: this.maxCanvasPixels,
10162 this._pages.push(pageView);
10165 const firstPageView = this._pages[0];
10167 if (firstPageView) {
10168 firstPageView.setPdfPage(firstPdfPage);
10169 this.linkService.cachePageRef(1, firstPdfPage.ref);
10172 if (this._spreadMode !== _ui_utils.SpreadMode.NONE) {
10173 this._updateSpreadMode();
10176 this._onePageRenderedOrForceFetch().then(() => {
10177 if (this.findController) {
10178 this.findController.setDocument(pdfDocument);
10181 if (this.enableScripting) {
10182 this._scriptingManager.setDocument(pdfDocument);
10185 if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > 7500) {
10186 this._pagesCapability.resolve();
10191 let getPagesLeft = pagesCount - 1;
10193 if (getPagesLeft <= 0) {
10194 this._pagesCapability.resolve();
10199 for (let pageNum = 2; pageNum <= pagesCount; ++pageNum) {
10200 pdfDocument.getPage(pageNum).then(pdfPage => {
10201 const pageView = this._pages[pageNum - 1];
10203 if (!pageView.pdfPage) {
10204 pageView.setPdfPage(pdfPage);
10207 this.linkService.cachePageRef(pageNum, pdfPage.ref);
10209 if (--getPagesLeft === 0) {
10210 this._pagesCapability.resolve();
10213 console.error(`Unable to get page ${pageNum} to initialize viewer`, reason);
10215 if (--getPagesLeft === 0) {
10216 this._pagesCapability.resolve();
10222 this.eventBus.dispatch("pagesinit
", {
10226 if (this.defaultRenderingQueue) {
10229 }).catch(reason => {
10230 console.error("Unable to initialize viewer
", reason);
10234 setPageLabels(labels) {
10235 if (!this.pdfDocument) {
10240 this._pageLabels = null;
10241 } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
10242 this._pageLabels = null;
10243 console.error(`${this._name}.setPageLabels: Invalid page labels.`);
10245 this._pageLabels = labels;
10248 for (let i = 0, ii = this._pages.length; i < ii; i++) {
10249 this._pages[i].setPageLabel(this._pageLabels?.[i] ?? null);
10255 this._currentPageNumber = 1;
10256 this._currentScale = _ui_utils.UNKNOWN_SCALE;
10257 this._currentScaleValue = null;
10258 this._pageLabels = null;
10259 this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
10260 this._location = null;
10261 this._pagesRotation = 0;
10262 this._optionalContentConfigPromise = null;
10263 this._pagesRequests = new WeakMap();
10264 this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
10265 this._onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
10266 this._pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
10267 this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
10268 this._spreadMode = _ui_utils.SpreadMode.NONE;
10270 if (this._onBeforeDraw) {
10271 this.eventBus._off("pagerender
", this._onBeforeDraw);
10273 this._onBeforeDraw = null;
10276 if (this._onAfterDraw) {
10277 this.eventBus._off("pagerendered
", this._onAfterDraw);
10279 this._onAfterDraw = null;
10282 this.viewer.textContent = "";
10284 this._updateScrollMode();
10288 if (this.pagesCount === 0) {
10300 (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
10303 _setScaleUpdatePages(newScale, newValue, noScroll = false, preset = false) {
10304 this._currentScaleValue = newValue.toString();
10306 if (isSameScale(this._currentScale, newScale)) {
10308 this.eventBus.dispatch("scalechanging
", {
10311 presetValue: newValue
10318 for (let i = 0, ii = this._pages.length; i < ii; i++) {
10319 this._pages[i].update(newScale);
10322 this._currentScale = newScale;
10325 let page = this._currentPageNumber,
10328 if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
10329 page = this._location.pageNumber;
10332 }, this._location.left, this._location.top, null];
10335 this.scrollPageIntoView({
10338 allowNegativeOffset: true
10342 this.eventBus.dispatch("scalechanging
", {
10345 presetValue: preset ? newValue : undefined
10348 if (this.defaultRenderingQueue) {
10353 get _pageWidthScaleFactor() {
10354 if (this._spreadMode !== _ui_utils.SpreadMode.NONE && this._scrollMode !== _ui_utils.ScrollMode.HORIZONTAL && !this.isInPresentationMode) {
10361 _setScale(value, noScroll = false) {
10362 let scale = parseFloat(value);
10365 this._setScaleUpdatePages(scale, value, noScroll, false);
10367 const currentPage = this._pages[this._currentPageNumber - 1];
10369 if (!currentPage) {
10373 const noPadding = this.isInPresentationMode || this.removePageBorders;
10374 let hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
10375 let vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
10377 if (!noPadding && this._isScrollModeHorizontal) {
10378 [hPadding, vPadding] = [vPadding, hPadding];
10381 const pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale / this._pageWidthScaleFactor;
10382 const pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
10385 case "page
-actual
":
10390 scale = pageWidthScale;
10393 case "page
-height
":
10394 scale = pageHeightScale;
10398 scale = Math.min(pageWidthScale, pageHeightScale);
10402 const horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
10403 scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
10407 console.error(`${this._name}._setScale: "${value}
" is an unknown zoom value.`);
10411 this._setScaleUpdatePages(scale, value, noScroll, true);
10415 _resetCurrentPageView() {
10416 if (this.isInPresentationMode) {
10417 this._setScale(this._currentScaleValue, true);
10420 const pageView = this._pages[this._currentPageNumber - 1];
10422 this._scrollIntoView({
10423 pageDiv: pageView.div
10427 pageLabelToPageNumber(label) {
10428 if (!this._pageLabels) {
10432 const i = this._pageLabels.indexOf(label);
10441 scrollPageIntoView({
10444 allowNegativeOffset = false,
10445 ignoreDestinationZoom = false
10447 if (!this.pdfDocument) {
10451 const pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
10454 console.error(`${this._name}.scrollPageIntoView: ` + `"${pageNumber}
" is not a valid pageNumber parameter.`);
10458 if (this.isInPresentationMode || !destArray) {
10459 this._setCurrentPageNumber(pageNumber, true);
10470 const changeOrientation = pageView.rotation % 180 !== 0;
10471 const pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
10472 const pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
10475 switch (destArray[1].name) {
10479 scale = destArray[4];
10480 x = x !== null ? x : 0;
10481 y = y !== null ? y : pageHeight;
10486 scale = "page
-fit
";
10492 scale = "page
-width
";
10494 if (y === null && this._location) {
10495 x = this._location.left;
10496 y = this._location.top;
10497 } else if (typeof y !== "number
") {
10507 height = pageHeight;
10508 scale = "page
-height
";
10514 width = destArray[4] - x;
10515 height = destArray[5] - y;
10516 const hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
10517 const vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
10518 widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
10519 heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
10520 scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
10524 console.error(`${this._name}.scrollPageIntoView: ` + `"${destArray[1].name}
" is not a valid destination type.`);
10528 if (!ignoreDestinationZoom) {
10529 if (scale && scale !== this._currentScale) {
10530 this.currentScaleValue = scale;
10531 } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
10532 this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
10536 if (scale === "page
-fit
" && !destArray[4]) {
10537 this._scrollIntoView({
10538 pageDiv: pageView.div,
10545 const boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
10546 let left = Math.min(boundingRect[0][0], boundingRect[1][0]);
10547 let top = Math.min(boundingRect[0][1], boundingRect[1][1]);
10549 if (!allowNegativeOffset) {
10550 left = Math.max(left, 0);
10551 top = Math.max(top, 0);
10554 this._scrollIntoView({
10555 pageDiv: pageView.div,
10564 _updateLocation(firstPage) {
10565 const currentScale = this._currentScale;
10566 const currentScaleValue = this._currentScaleValue;
10567 const normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
10568 const pageNumber = firstPage.id;
10569 let pdfOpenParams = "#page
=" + pageNumber;
10570 pdfOpenParams += "&zoom
=" + normalizedScaleValue;
10571 const currentPageView = this._pages[pageNumber - 1];
10572 const container = this.container;
10573 const topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
10574 const intLeft = Math.round(topLeft[0]);
10575 const intTop = Math.round(topLeft[1]);
10576 pdfOpenParams += "," + intLeft + "," + intTop;
10579 scale: normalizedScaleValue,
10582 rotation: this._pagesRotation,
10587 _updateHelper(visiblePages) {
10588 throw new Error("Not implemented
: _updateHelper
");
10592 const visible = this._getVisiblePages();
10594 const visiblePages = visible.views,
10595 numVisiblePages = visiblePages.length;
10597 if (numVisiblePages === 0) {
10601 const newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
10603 this._buffer.resize(newCacheSize, visiblePages);
10605 this.renderingQueue.renderHighestPriority(visible);
10607 this._updateHelper(visiblePages);
10609 this._updateLocation(visible.first);
10611 this.eventBus.dispatch("updateviewarea
", {
10613 location: this._location
10617 containsElement(element) {
10618 return this.container.contains(element);
10622 this.container.focus();
10625 get _isScrollModeHorizontal() {
10626 return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
10629 get _isContainerRtl() {
10630 return getComputedStyle(this.container).direction === "rtl
";
10633 get isInPresentationMode() {
10634 return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
10637 get isChangingPresentationMode() {
10638 return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
10641 get isHorizontalScrollbarEnabled() {
10642 return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
10645 get isVerticalScrollbarEnabled() {
10646 return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
10649 _getCurrentVisiblePage() {
10650 if (!this.pagesCount) {
10656 const pageView = this._pages[this._currentPageNumber - 1];
10657 const element = pageView.div;
10660 x: element.offsetLeft + element.clientLeft,
10661 y: element.offsetTop + element.clientTop,
10671 _getVisiblePages() {
10672 return (0, _ui_utils.getVisibleElements)({
10673 scrollEl: this.container,
10674 views: this._pages,
10675 sortByVisibility: true,
10676 horizontal: this._isScrollModeHorizontal,
10677 rtl: this._isScrollModeHorizontal && this._isContainerRtl
10681 isPageVisible(pageNumber) {
10682 if (!this.pdfDocument) {
10686 if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
10687 console.error(`${this._name}.isPageVisible: "${pageNumber}
" is not a valid page.`);
10691 return this._getVisiblePages().views.some(function (view) {
10692 return view.id === pageNumber;
10696 isPageCached(pageNumber) {
10697 if (!this.pdfDocument || !this._buffer) {
10701 if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
10702 console.error(`${this._name}.isPageCached: "${pageNumber}
" is not a valid page.`);
10706 const pageView = this._pages[pageNumber - 1];
10712 return this._buffer.has(pageView);
10716 for (let i = 0, ii = this._pages.length; i < ii; i++) {
10717 if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
10718 this._pages[i].reset();
10723 _cancelRendering() {
10724 for (let i = 0, ii = this._pages.length; i < ii; i++) {
10725 if (this._pages[i]) {
10726 this._pages[i].cancelRendering();
10731 _ensurePdfPageLoaded(pageView) {
10732 if (pageView.pdfPage) {
10733 return Promise.resolve(pageView.pdfPage);
10736 if (this._pagesRequests.has(pageView)) {
10737 return this._pagesRequests.get(pageView);
10740 const promise = this.pdfDocument.getPage(pageView.id).then(pdfPage => {
10741 if (!pageView.pdfPage) {
10742 pageView.setPdfPage(pdfPage);
10745 this._pagesRequests.delete(pageView);
10748 }).catch(reason => {
10749 console.error("Unable to
get page
for page view
", reason);
10751 this._pagesRequests.delete(pageView);
10754 this._pagesRequests.set(pageView, promise);
10759 forceRendering(currentlyVisiblePages) {
10760 const visiblePages = currentlyVisiblePages || this._getVisiblePages();
10762 const scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
10763 const pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
10766 this._ensurePdfPageLoaded(pageView).then(() => {
10767 this.renderingQueue.renderView(pageView);
10776 createTextLayerBuilder(textLayerDiv, pageIndex, viewport, enhanceTextSelection = false, eventBus) {
10777 return new _text_layer_builder.TextLayerBuilder({
10782 findController: this.isInPresentationMode ? null : this.findController,
10783 enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
10787 createAnnotationLayerBuilder(pageDiv, pdfPage, annotationStorage = null, imageResourcesPath = "", renderInteractiveForms = false, l10n = _l10n_utils.NullL10n, enableScripting = null, hasJSActionsPromise = null, mouseState = null) {
10788 return new _annotation_layer_builder.AnnotationLayerBuilder({
10791 annotationStorage: annotationStorage || this.pdfDocument?.annotationStorage,
10792 imageResourcesPath,
10793 renderInteractiveForms,
10794 linkService: this.linkService,
10795 downloadManager: this.downloadManager,
10797 enableScripting: enableScripting ?? this.enableScripting,
10798 hasJSActionsPromise: hasJSActionsPromise || this.pdfDocument?.hasJSActions(),
10799 mouseState: mouseState || this._scriptingManager?.mouseState
10803 createXfaLayerBuilder(pageDiv, pdfPage, annotationStorage = null) {
10804 return new _xfa_layer_builder.XfaLayerBuilder({
10807 annotationStorage: annotationStorage || this.pdfDocument?.annotationStorage
10811 createStructTreeLayerBuilder(pdfPage) {
10812 return new _struct_tree_layer_builder.StructTreeLayerBuilder({
10817 get hasEqualPageSizes() {
10818 const firstPageView = this._pages[0];
10820 for (let i = 1, ii = this._pages.length; i < ii; ++i) {
10821 const pageView = this._pages[i];
10823 if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
10831 getPagesOverview() {
10832 return this._pages.map(pageView => {
10833 const viewport = pageView.pdfPage.getViewport({
10837 if (!this.enablePrintAutoRotate || (0, _ui_utils.isPortraitOrientation)(viewport)) {
10839 width: viewport.width,
10840 height: viewport.height,
10841 rotation: viewport.rotation
10846 width: viewport.height,
10847 height: viewport.width,
10848 rotation: (viewport.rotation - 90) % 360
10853 get optionalContentConfigPromise() {
10854 if (!this.pdfDocument) {
10855 return Promise.resolve(null);
10858 if (!this._optionalContentConfigPromise) {
10859 return this.pdfDocument.getOptionalContentConfig();
10862 return this._optionalContentConfigPromise;
10865 set optionalContentConfigPromise(promise) {
10866 if (!(promise instanceof Promise)) {
10867 throw new Error(`Invalid optionalContentConfigPromise: ${promise}`);
10870 if (!this.pdfDocument) {
10874 if (!this._optionalContentConfigPromise) {
10878 this._optionalContentConfigPromise = promise;
10880 for (const pageView of this._pages) {
10881 pageView.update(pageView.scale, pageView.rotation, promise);
10885 this.eventBus.dispatch("optionalcontentconfigchanged
", {
10892 return this._scrollMode;
10895 set scrollMode(mode) {
10896 if (this._scrollMode === mode) {
10900 if (!(0, _ui_utils.isValidScrollMode)(mode)) {
10901 throw new Error(`Invalid scroll mode: ${mode}`);
10904 this._scrollMode = mode;
10905 this.eventBus.dispatch("scrollmodechanged
", {
10910 this._updateScrollMode(this._currentPageNumber);
10913 _updateScrollMode(pageNumber = null) {
10914 const scrollMode = this._scrollMode,
10915 viewer = this.viewer;
10916 viewer.classList.toggle("scrollHorizontal
", scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
10917 viewer.classList.toggle("scrollWrapped
", scrollMode === _ui_utils.ScrollMode.WRAPPED);
10919 if (!this.pdfDocument || !pageNumber) {
10923 if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
10924 this._setScale(this._currentScaleValue, true);
10927 this._setCurrentPageNumber(pageNumber, true);
10933 return this._spreadMode;
10936 set spreadMode(mode) {
10937 if (this._spreadMode === mode) {
10941 if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
10942 throw new Error(`Invalid spread mode: ${mode}`);
10945 this._spreadMode = mode;
10946 this.eventBus.dispatch("spreadmodechanged
", {
10951 this._updateSpreadMode(this._currentPageNumber);
10954 _updateSpreadMode(pageNumber = null) {
10955 if (!this.pdfDocument) {
10959 const viewer = this.viewer,
10960 pages = this._pages;
10961 viewer.textContent = "";
10963 if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
10964 for (let i = 0, iMax = pages.length; i < iMax; ++i) {
10965 viewer.appendChild(pages[i].div);
10968 const parity = this._spreadMode - 1;
10971 for (let i = 0, iMax = pages.length; i < iMax; ++i) {
10972 if (spread === null) {
10973 spread = document.createElement("div
");
10974 spread.className = "spread
";
10975 viewer.appendChild(spread);
10976 } else if (i % 2 === parity) {
10977 spread = spread.cloneNode(false);
10978 viewer.appendChild(spread);
10981 spread.appendChild(pages[i].div);
10989 if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
10990 this._setScale(this._currentScaleValue, true);
10993 this._setCurrentPageNumber(pageNumber, true);
10998 _getPageAdvance(currentPageNumber, previous = false) {
10999 if (this.isInPresentationMode) {
11003 switch (this._scrollMode) {
11004 case _ui_utils.ScrollMode.WRAPPED:
11008 } = this._getVisiblePages(),
11009 pageLayout = new Map();
11017 if (percent === 0 || widthPercent < 100) {
11021 let yArray = pageLayout.get(y);
11024 pageLayout.set(y, yArray || (yArray = []));
11030 for (const yArray of pageLayout.values()) {
11031 const currentIndex = yArray.indexOf(currentPageNumber);
11033 if (currentIndex === -1) {
11037 const numPages = yArray.length;
11039 if (numPages === 1) {
11044 for (let i = currentIndex - 1, ii = 0; i >= ii; i--) {
11045 const currentId = yArray[i],
11046 expectedId = yArray[i + 1] - 1;
11048 if (currentId < expectedId) {
11049 return currentPageNumber - expectedId;
11053 for (let i = currentIndex + 1, ii = numPages; i < ii; i++) {
11054 const currentId = yArray[i],
11055 expectedId = yArray[i - 1] + 1;
11057 if (currentId > expectedId) {
11058 return expectedId - currentPageNumber;
11064 const firstId = yArray[0];
11066 if (firstId < currentPageNumber) {
11067 return currentPageNumber - firstId + 1;
11070 const lastId = yArray[numPages - 1];
11072 if (lastId > currentPageNumber) {
11073 return lastId - currentPageNumber + 1;
11083 case _ui_utils.ScrollMode.HORIZONTAL:
11088 case _ui_utils.ScrollMode.VERTICAL:
11090 if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
11094 const parity = this._spreadMode - 1;
11096 if (previous && currentPageNumber % 2 !== parity) {
11098 } else if (!previous && currentPageNumber % 2 === parity) {
11104 } = this._getVisiblePages(),
11105 expectedId = previous ? currentPageNumber - 1 : currentPageNumber + 1;
11112 if (id !== expectedId) {
11116 if (percent > 0 && widthPercent === 100) {
11131 const currentPageNumber = this._currentPageNumber,
11132 pagesCount = this.pagesCount;
11134 if (currentPageNumber >= pagesCount) {
11138 const advance = this._getPageAdvance(currentPageNumber, false) || 1;
11139 this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount);
11144 const currentPageNumber = this._currentPageNumber;
11146 if (currentPageNumber <= 1) {
11150 const advance = this._getPageAdvance(currentPageNumber, true) || 1;
11151 this.currentPageNumber = Math.max(currentPageNumber - advance, 1);
11157 exports.BaseViewer = BaseViewer;
11161 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
11165 Object.defineProperty(exports, "__esModule
", ({
11168 exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
11170 var _pdfjsLib = __webpack_require__(5);
11172 var _l10n_utils = __webpack_require__(30);
11174 var _pdf_link_service = __webpack_require__(19);
11176 class AnnotationLayerBuilder {
11182 annotationStorage = null,
11183 imageResourcesPath = "",
11184 renderInteractiveForms = true,
11185 l10n = _l10n_utils.NullL10n,
11186 enableScripting = false,
11187 hasJSActionsPromise = null,
11190 this.pageDiv = pageDiv;
11191 this.pdfPage = pdfPage;
11192 this.linkService = linkService;
11193 this.downloadManager = downloadManager;
11194 this.imageResourcesPath = imageResourcesPath;
11195 this.renderInteractiveForms = renderInteractiveForms;
11197 this.annotationStorage = annotationStorage;
11198 this.enableScripting = enableScripting;
11199 this._hasJSActionsPromise = hasJSActionsPromise;
11200 this._mouseState = mouseState;
11202 this._cancelled = false;
11205 render(viewport, intent = "display
") {
11206 return Promise.all([this.pdfPage.getAnnotations({
11208 }), this._hasJSActionsPromise]).then(([annotations, hasJSActions = false]) => {
11209 if (this._cancelled) {
11213 if (annotations.length === 0) {
11217 const parameters = {
11218 viewport: viewport.clone({
11223 page: this.pdfPage,
11224 imageResourcesPath: this.imageResourcesPath,
11225 renderInteractiveForms: this.renderInteractiveForms,
11226 linkService: this.linkService,
11227 downloadManager: this.downloadManager,
11228 annotationStorage: this.annotationStorage,
11229 enableScripting: this.enableScripting,
11231 mouseState: this._mouseState
11235 _pdfjsLib.AnnotationLayer.update(parameters);
11237 this.div = document.createElement("div
");
11238 this.div.className = "annotationLayer
";
11239 this.pageDiv.appendChild(this.div);
11240 parameters.div = this.div;
11242 _pdfjsLib.AnnotationLayer.render(parameters);
11244 this.l10n.translate(this.div);
11250 this._cancelled = true;
11258 this.div.hidden = true;
11263 exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
11265 class DefaultAnnotationLayerFactory {
11266 createAnnotationLayerBuilder(pageDiv, pdfPage, annotationStorage = null, imageResourcesPath = "", renderInteractiveForms = true, l10n = _l10n_utils.NullL10n, enableScripting = false, hasJSActionsPromise = null, mouseState = null) {
11267 return new AnnotationLayerBuilder({
11270 imageResourcesPath,
11271 renderInteractiveForms,
11272 linkService: new _pdf_link_service.SimpleLinkService(),
11276 hasJSActionsPromise,
11283 exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
11287 /***/ ((__unused_webpack_module, exports) => {
11291 Object.defineProperty(exports, "__esModule
", ({
11294 exports.fixupLangCode = fixupLangCode;
11295 exports.getL10nFallback = getL10nFallback;
11296 exports.NullL10n = void 0;
11297 const DEFAULT_L10N_STRINGS = {
11298 of_pages: "of {{pagesCount
}}",
11299 page_of_pages: "({{pageNumber
}} of {{pagesCount
}})",
11300 document_properties_kb: "{{size_kb
}} KB ({{size_b
}} bytes
)",
11301 document_properties_mb: "{{size_mb
}} MB ({{size_b
}} bytes
)",
11302 document_properties_date_string: "{{date
}}, {{time
}}",
11303 document_properties_page_size_unit_inches: "in",
11304 document_properties_page_size_unit_millimeters: "mm
",
11305 document_properties_page_size_orientation_portrait: "portrait
",
11306 document_properties_page_size_orientation_landscape: "landscape
",
11307 document_properties_page_size_name_a3: "A3
",
11308 document_properties_page_size_name_a4: "A4
",
11309 document_properties_page_size_name_letter: "Letter
",
11310 document_properties_page_size_name_legal: "Legal
",
11311 document_properties_page_size_dimension_string: "{{width
}} × {{height
}} {{unit
}} ({{orientation
}})",
11312 document_properties_page_size_dimension_name_string: "{{width
}} × {{height
}} {{unit
}} ({{name
}}, {{orientation
}})",
11313 document_properties_linearized_yes: "Yes
",
11314 document_properties_linearized_no: "No
",
11315 print_progress_percent: "{{progress
}}%",
11316 "toggle_sidebar
.title
": "Toggle Sidebar
",
11317 "toggle_sidebar_notification2
.title
": "Toggle
Sidebar (document contains outline
/attachments/layers)",
11318 additional_layers: "Additional Layers
",
11319 page_landmark: "Page
{{page
}}",
11320 thumb_page_title: "Page
{{page
}}",
11321 thumb_page_canvas: "Thumbnail
of Page
{{page
}}",
11322 find_reached_top: "Reached top
of document
, continued
from bottom
",
11323 find_reached_bottom: "Reached end
of document
, continued
from top
",
11324 "find_match_count
[one
]": "{{current
}} of {{total
}} match
",
11325 "find_match_count
[other
]": "{{current
}} of {{total
}} matches
",
11326 "find_match_count_limit
[one
]": "More than
{{limit
}} match
",
11327 "find_match_count_limit
[other
]": "More than
{{limit
}} matches
",
11328 find_not_found: "Phrase not found
",
11329 error_version_info: "PDF
.js v
{{version
}} (build
: {{build
}})",
11330 error_message: "Message
: {{message
}}",
11331 error_stack: "Stack
: {{stack
}}",
11332 error_file: "File
: {{file
}}",
11333 error_line: "Line
: {{line
}}",
11334 rendering_error: "An error occurred
while rendering the page
.",
11335 page_scale_width: "Page Width
",
11336 page_scale_fit: "Page Fit
",
11337 page_scale_auto: "Automatic Zoom
",
11338 page_scale_actual: "Actual Size
",
11339 page_scale_percent: "{{scale
}}%",
11340 loading: "Loading
…",
11341 loading_error: "An error occurred
while loading the PDF
.",
11342 invalid_file_error: "Invalid or corrupted PDF file
.",
11343 missing_file_error: "Missing PDF file
.",
11344 unexpected_response_error: "Unexpected server response
.",
11345 printing_not_supported: "Warning
: Printing is not fully supported by
this browser
.",
11346 printing_not_ready: "Warning
: The PDF is not fully loaded
for printing
.",
11347 web_fonts_disabled: "Web fonts are disabled
: unable to
use embedded PDF fonts
."
11350 function getL10nFallback(key, args) {
11352 case "find_match_count
":
11353 key = `find_match_count[${args.total === 1 ? "one" : "other"}]`;
11356 case "find_match_count_limit
":
11357 key = `find_match_count_limit[${args.limit === 1 ? "one" : "other"}]`;
11361 return DEFAULT_L10N_STRINGS[key] || "";
11364 const PARTIAL_LANG_CODES = {
11381 function fixupLangCode(langCode) {
11382 return PARTIAL_LANG_CODES[langCode?.toLowerCase()] || langCode;
11385 function formatL10nValue(text, args) {
11390 return text.replace(/\{\{\s*(\w+)\s*\}\}/g, (all, name) => {
11391 return name in args ? args[name] : "{{" + name + "}}";
11396 async getLanguage() {
11400 async getDirection() {
11404 async get(key, args = null, fallback = getL10nFallback(key, args)) {
11405 return formatL10nValue(fallback, args);
11408 async translate(element) {}
11411 exports.NullL10n = NullL10n;
11415 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
11419 Object.defineProperty(exports, "__esModule
", ({
11422 exports.PDFPageView = void 0;
11424 var _ui_utils = __webpack_require__(4);
11426 var _pdfjsLib = __webpack_require__(5);
11428 var _l10n_utils = __webpack_require__(30);
11430 var _pdf_rendering_queue = __webpack_require__(8);
11432 var _viewer_compatibility = __webpack_require__(2);
11434 const MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
11436 class PDFPageView {
11437 constructor(options) {
11438 const container = options.container;
11439 const defaultViewport = options.defaultViewport;
11440 this.id = options.id;
11441 this.renderingId = "page
" + this.id;
11442 this.pdfPage = null;
11443 this.pageLabel = null;
11445 this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
11446 this.viewport = defaultViewport;
11447 this.pdfPageRotate = defaultViewport.rotation;
11448 this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
11449 this.hasRestrictedScaling = false;
11450 this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
11451 this.imageResourcesPath = options.imageResourcesPath || "";
11452 this.renderInteractiveForms = options.renderInteractiveForms !== false;
11453 this.useOnlyCssZoom = options.useOnlyCssZoom || false;
11454 this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
11455 this.eventBus = options.eventBus;
11456 this.renderingQueue = options.renderingQueue;
11457 this.textLayerFactory = options.textLayerFactory;
11458 this.annotationLayerFactory = options.annotationLayerFactory;
11459 this.xfaLayerFactory = options.xfaLayerFactory;
11460 this.structTreeLayerFactory = options.structTreeLayerFactory;
11461 this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
11462 this.l10n = options.l10n || _l10n_utils.NullL10n;
11463 this.paintTask = null;
11464 this.paintedViewportMap = new WeakMap();
11465 this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
11466 this.resume = null;
11467 this._renderError = null;
11468 this.annotationLayer = null;
11469 this.textLayer = null;
11470 this.zoomLayer = null;
11471 this.xfaLayer = null;
11472 this.structTreeLayer = null;
11473 const div = document.createElement("div
");
11474 div.className = "page
";
11475 div.style.width = Math.floor(this.viewport.width) + "px
";
11476 div.style.height = Math.floor(this.viewport.height) + "px
";
11477 div.setAttribute("data
-page
-number
", this.id);
11478 div.setAttribute("role
", "region
");
11479 this.l10n.get("page_landmark
", {
11482 div.setAttribute("aria
-label
", msg);
11485 container.appendChild(div);
11488 setPdfPage(pdfPage) {
11489 this.pdfPage = pdfPage;
11490 this.pdfPageRotate = pdfPage.rotate;
11491 const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
11492 this.viewport = pdfPage.getViewport({
11493 scale: this.scale * _ui_utils.CSS_UNITS,
11494 rotation: totalRotation
11502 if (this.pdfPage) {
11503 this.pdfPage.cleanup();
11507 async _renderAnnotationLayer() {
11511 await this.annotationLayer.render(this.viewport, "display
");
11515 this.eventBus.dispatch("annotationlayerrendered
", {
11517 pageNumber: this.id,
11523 async _renderXfaLayer() {
11527 await this.xfaLayer.render(this.viewport, "display
");
11531 this.eventBus.dispatch("xfalayerrendered
", {
11533 pageNumber: this.id,
11539 _resetZoomLayer(removeFromDOM = false) {
11540 if (!this.zoomLayer) {
11544 const zoomLayerCanvas = this.zoomLayer.firstChild;
11545 this.paintedViewportMap.delete(zoomLayerCanvas);
11546 zoomLayerCanvas.width = 0;
11547 zoomLayerCanvas.height = 0;
11549 if (removeFromDOM) {
11550 this.zoomLayer.remove();
11553 this.zoomLayer = null;
11557 keepZoomLayer = false,
11558 keepAnnotationLayer = false,
11559 keepXfaLayer = false
11561 this.cancelRendering({
11562 keepAnnotationLayer,
11565 this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
11566 const div = this.div;
11567 div.style.width = Math.floor(this.viewport.width) + "px
";
11568 div.style.height = Math.floor(this.viewport.height) + "px
";
11569 const childNodes = div.childNodes,
11570 zoomLayerNode = keepZoomLayer && this.zoomLayer || null,
11571 annotationLayerNode = keepAnnotationLayer && this.annotationLayer?.div || null,
11572 xfaLayerNode = keepXfaLayer && this.xfaLayer?.div || null;
11574 for (let i = childNodes.length - 1; i >= 0; i--) {
11575 const node = childNodes[i];
11578 case zoomLayerNode:
11579 case annotationLayerNode:
11584 div.removeChild(node);
11587 div.removeAttribute("data
-loaded
");
11589 if (annotationLayerNode) {
11590 this.annotationLayer.hide();
11593 if (xfaLayerNode) {
11594 this.xfaLayer.hide();
11597 if (!zoomLayerNode) {
11599 this.paintedViewportMap.delete(this.canvas);
11600 this.canvas.width = 0;
11601 this.canvas.height = 0;
11602 delete this.canvas;
11605 this._resetZoomLayer();
11609 this.paintedViewportMap.delete(this.svg);
11613 this.loadingIconDiv = document.createElement("div
");
11614 this.loadingIconDiv.className = "loadingIcon
";
11615 this.loadingIconDiv.setAttribute("role
", "img
");
11616 this.l10n.get("loading
").then(msg => {
11617 this.loadingIconDiv?.setAttribute("aria
-label
", msg);
11619 div.appendChild(this.loadingIconDiv);
11622 update(scale, rotation, optionalContentConfigPromise = null) {
11623 this.scale = scale || this.scale;
11625 if (typeof rotation !== "undefined") {
11626 this.rotation = rotation;
11629 if (optionalContentConfigPromise instanceof Promise) {
11630 this._optionalContentConfigPromise = optionalContentConfigPromise;
11633 const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
11634 this.viewport = this.viewport.clone({
11635 scale: this.scale * _ui_utils.CSS_UNITS,
11636 rotation: totalRotation
11640 this.cssTransform({
11642 redrawAnnotationLayer: true,
11643 redrawXfaLayer: true
11645 this.eventBus.dispatch("pagerendered
", {
11647 pageNumber: this.id,
11648 cssTransform: true,
11649 timestamp: performance.now(),
11650 error: this._renderError
11655 let isScalingRestricted = false;
11657 if (this.canvas && this.maxCanvasPixels > 0) {
11658 const outputScale = this.outputScale;
11660 if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
11661 isScalingRestricted = true;
11666 if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
11667 this.cssTransform({
11668 target: this.canvas,
11669 redrawAnnotationLayer: true,
11670 redrawXfaLayer: true
11672 this.eventBus.dispatch("pagerendered
", {
11674 pageNumber: this.id,
11675 cssTransform: true,
11676 timestamp: performance.now(),
11677 error: this._renderError
11682 if (!this.zoomLayer && !this.canvas.hidden) {
11683 this.zoomLayer = this.canvas.parentNode;
11684 this.zoomLayer.style.position = "absolute
";
11688 if (this.zoomLayer) {
11689 this.cssTransform({
11690 target: this.zoomLayer.firstChild
11695 keepZoomLayer: true,
11696 keepAnnotationLayer: true,
11702 keepAnnotationLayer = false,
11703 keepXfaLayer = false
11705 if (this.paintTask) {
11706 this.paintTask.cancel();
11707 this.paintTask = null;
11710 this.resume = null;
11712 if (this.textLayer) {
11713 this.textLayer.cancel();
11714 this.textLayer = null;
11717 if (this.annotationLayer && (!keepAnnotationLayer || !this.annotationLayer.div)) {
11718 this.annotationLayer.cancel();
11719 this.annotationLayer = null;
11722 if (this.xfaLayer && (!keepXfaLayer || !this.xfaLayer.div)) {
11723 this.xfaLayer.cancel();
11724 this.xfaLayer = null;
11727 if (this._onTextLayerRendered) {
11728 this.eventBus._off("textlayerrendered
", this._onTextLayerRendered);
11730 this._onTextLayerRendered = null;
11736 redrawAnnotationLayer = false,
11737 redrawXfaLayer = false
11739 const width = this.viewport.width;
11740 const height = this.viewport.height;
11741 const div = this.div;
11742 target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + "px
";
11743 target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + "px
";
11744 const relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
11745 const absRotation = Math.abs(relativeRotation);
11749 if (absRotation === 90 || absRotation === 270) {
11750 scaleX = height / width;
11751 scaleY = width / height;
11754 target.style.transform = `rotate(${relativeRotation}deg) scale(${scaleX}, ${scaleY})`;
11756 if (this.textLayer) {
11757 const textLayerViewport = this.textLayer.viewport;
11758 const textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
11759 const textAbsRotation = Math.abs(textRelativeRotation);
11760 let scale = width / textLayerViewport.width;
11762 if (textAbsRotation === 90 || textAbsRotation === 270) {
11763 scale = width / textLayerViewport.height;
11766 const textLayerDiv = this.textLayer.textLayerDiv;
11767 let transX, transY;
11769 switch (textAbsRotation) {
11771 transX = transY = 0;
11776 transY = "-" + textLayerDiv.style.height;
11780 transX = "-" + textLayerDiv.style.width;
11781 transY = "-" + textLayerDiv.style.height;
11785 transX = "-" + textLayerDiv.style.width;
11790 console.error("Bad rotation value
.");
11794 textLayerDiv.style.transform = `rotate(${textAbsRotation}deg) ` + `scale(${scale}) ` + `translate(${transX}, ${transY})`;
11795 textLayerDiv.style.transformOrigin = "0% 0%";
11798 if (redrawAnnotationLayer && this.annotationLayer) {
11799 this._renderAnnotationLayer();
11802 if (redrawXfaLayer && this.xfaLayer) {
11803 this._renderXfaLayer();
11808 return this.viewport.width;
11812 return this.viewport.height;
11815 getPagePoint(x, y) {
11816 return this.viewport.convertToPdfPoint(x, y);
11820 if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
11821 console.error("Must be
in new state before drawing
");
11831 this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
11833 if (this.loadingIconDiv) {
11834 div.removeChild(this.loadingIconDiv);
11835 delete this.loadingIconDiv;
11838 return Promise.reject(new Error("pdfPage is not loaded
"));
11841 this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
11842 const canvasWrapper = document.createElement("div
");
11843 canvasWrapper.style.width = div.style.width;
11844 canvasWrapper.style.height = div.style.height;
11845 canvasWrapper.classList.add("canvasWrapper
");
11847 if (this.annotationLayer?.div) {
11848 div.insertBefore(canvasWrapper, this.annotationLayer.div);
11850 div.appendChild(canvasWrapper);
11853 let textLayer = null;
11855 if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
11856 const textLayerDiv = document.createElement("div
");
11857 textLayerDiv.className = "textLayer
";
11858 textLayerDiv.style.width = canvasWrapper.style.width;
11859 textLayerDiv.style.height = canvasWrapper.style.height;
11861 if (this.annotationLayer?.div) {
11862 div.insertBefore(textLayerDiv, this.annotationLayer.div);
11864 div.appendChild(textLayerDiv);
11867 textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE, this.eventBus);
11870 this.textLayer = textLayer;
11872 if (this.xfaLayer?.div) {
11873 div.appendChild(this.xfaLayer.div);
11876 let renderContinueCallback = null;
11878 if (this.renderingQueue) {
11879 renderContinueCallback = cont => {
11880 if (!this.renderingQueue.isHighestPriority(this)) {
11881 this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
11883 this.resume = () => {
11884 this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
11895 const finishPaintTask = async (error = null) => {
11896 if (paintTask === this.paintTask) {
11897 this.paintTask = null;
11900 if (error instanceof _pdfjsLib.RenderingCancelledException) {
11901 this._renderError = null;
11905 this._renderError = error;
11906 this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
11908 if (this.loadingIconDiv) {
11909 div.removeChild(this.loadingIconDiv);
11910 delete this.loadingIconDiv;
11913 this._resetZoomLayer(true);
11915 this.eventBus.dispatch("pagerendered
", {
11917 pageNumber: this.id,
11918 cssTransform: false,
11919 timestamp: performance.now(),
11920 error: this._renderError
11928 const paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
11929 paintTask.onRenderContinue = renderContinueCallback;
11930 this.paintTask = paintTask;
11931 const resultPromise = paintTask.promise.then(() => {
11932 return finishPaintTask(null).then(() => {
11934 const readableStream = pdfPage.streamTextContent({
11935 normalizeWhitespace: true,
11936 includeMarkedContent: true
11938 textLayer.setTextContentStream(readableStream);
11939 textLayer.render();
11942 }, function (reason) {
11943 return finishPaintTask(reason);
11946 if (this.annotationLayerFactory) {
11947 if (!this.annotationLayer) {
11948 this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, null, this.imageResourcesPath, this.renderInteractiveForms, this.l10n, null, null, null);
11951 this._renderAnnotationLayer();
11954 if (this.xfaLayerFactory) {
11955 if (!this.xfaLayer) {
11956 this.xfaLayer = this.xfaLayerFactory.createXfaLayerBuilder(div, pdfPage, null);
11959 this._renderXfaLayer();
11962 if (this.structTreeLayerFactory && this.textLayer && this.canvas) {
11963 this._onTextLayerRendered = event => {
11964 if (event.pageNumber !== this.id) {
11968 this.eventBus._off("textlayerrendered
", this._onTextLayerRendered);
11970 this._onTextLayerRendered = null;
11972 if (!this.canvas) {
11976 this.pdfPage.getStructTree().then(tree => {
11981 if (!this.canvas) {
11985 const treeDom = this.structTreeLayer.render(tree);
11986 treeDom.classList.add("structTree
");
11987 this.canvas.appendChild(treeDom);
11991 this.eventBus._on("textlayerrendered
", this._onTextLayerRendered);
11993 this.structTreeLayer = this.structTreeLayerFactory.createStructTreeLayerBuilder(pdfPage);
11996 div.setAttribute("data
-loaded
", true);
11997 this.eventBus.dispatch("pagerender
", {
11999 pageNumber: this.id
12001 return resultPromise;
12004 paintOnCanvas(canvasWrapper) {
12005 const renderCapability = (0, _pdfjsLib.createPromiseCapability)();
12007 promise: renderCapability.promise,
12009 onRenderContinue(cont) {
12014 renderTask.cancel();
12018 const viewport = this.viewport;
12019 const canvas = document.createElement("canvas
");
12020 canvas.hidden = true;
12021 let isCanvasHidden = true;
12023 const showCanvas = function () {
12024 if (isCanvasHidden) {
12025 canvas.hidden = false;
12026 isCanvasHidden = false;
12030 canvasWrapper.appendChild(canvas);
12031 this.canvas = canvas;
12032 canvas.mozOpaque = true;
12033 const ctx = canvas.getContext("2d
", {
12036 const outputScale = (0, _ui_utils.getOutputScale)(ctx);
12037 this.outputScale = outputScale;
12039 if (this.useOnlyCssZoom) {
12040 const actualSizeViewport = viewport.clone({
12041 scale: _ui_utils.CSS_UNITS
12043 outputScale.sx *= actualSizeViewport.width / viewport.width;
12044 outputScale.sy *= actualSizeViewport.height / viewport.height;
12045 outputScale.scaled = true;
12048 if (this.maxCanvasPixels > 0) {
12049 const pixelsInViewport = viewport.width * viewport.height;
12050 const maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
12052 if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
12053 outputScale.sx = maxScale;
12054 outputScale.sy = maxScale;
12055 outputScale.scaled = true;
12056 this.hasRestrictedScaling = true;
12058 this.hasRestrictedScaling = false;
12062 const sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
12063 const sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
12064 canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
12065 canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
12066 canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + "px
";
12067 canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + "px
";
12068 this.paintedViewportMap.set(canvas, viewport);
12069 const transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
12070 const renderContext = {
12071 canvasContext: ctx,
12073 viewport: this.viewport,
12074 renderInteractiveForms: this.renderInteractiveForms,
12075 optionalContentConfigPromise: this._optionalContentConfigPromise
12077 const renderTask = this.pdfPage.render(renderContext);
12079 renderTask.onContinue = function (cont) {
12082 if (result.onRenderContinue) {
12083 result.onRenderContinue(cont);
12089 renderTask.promise.then(function () {
12091 renderCapability.resolve(undefined);
12092 }, function (error) {
12094 renderCapability.reject(error);
12099 paintOnSvg(wrapper) {
12100 let cancelled = false;
12102 const ensureNotCancelled = () => {
12104 throw new _pdfjsLib.RenderingCancelledException(`Rendering cancelled, page ${this.id}`, "svg
");
12108 const pdfPage = this.pdfPage;
12109 const actualSizeViewport = this.viewport.clone({
12110 scale: _ui_utils.CSS_UNITS
12112 const promise = pdfPage.getOperatorList().then(opList => {
12113 ensureNotCancelled();
12114 const svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs, _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL);
12115 return svgGfx.getSVG(opList, actualSizeViewport).then(svg => {
12116 ensureNotCancelled();
12118 this.paintedViewportMap.set(svg, actualSizeViewport);
12119 svg.style.width = wrapper.style.width;
12120 svg.style.height = wrapper.style.height;
12121 this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
12122 wrapper.appendChild(svg);
12128 onRenderContinue(cont) {
12139 setPageLabel(label) {
12140 this.pageLabel = typeof label === "string
" ? label : null;
12142 if (this.pageLabel !== null) {
12143 this.div.setAttribute("data
-page
-label
", this.pageLabel);
12145 this.div.removeAttribute("data
-page
-label
");
12151 exports.PDFPageView = PDFPageView;
12155 /***/ ((__unused_webpack_module, exports) => {
12159 Object.defineProperty(exports, "__esModule
", ({
12162 exports.StructTreeLayerBuilder = exports.DefaultStructTreeLayerFactory = void 0;
12163 const PDF_ROLE_TO_HTML_ROLE = {
12165 DocumentFragment: null,
12195 TH: "columnheader
",
12197 THead: "columnheader
",
12205 const HEADING_PATTERN = /^H(\d+)$/;
12207 class StructTreeLayerBuilder {
12211 this.pdfPage = pdfPage;
12214 render(structTree) {
12215 return this._walk(structTree);
12218 _setAttributes(structElement, htmlElement) {
12219 if (structElement.alt !== undefined) {
12220 htmlElement.setAttribute("aria
-label
", structElement.alt);
12223 if (structElement.id !== undefined) {
12224 htmlElement.setAttribute("aria
-owns
", structElement.id);
12233 const element = document.createElement("span
");
12235 if ("role
" in node) {
12239 const match = role.match(HEADING_PATTERN);
12242 element.setAttribute("role
", "heading
");
12243 element.setAttribute("aria
-level
", match[1]);
12244 } else if (PDF_ROLE_TO_HTML_ROLE[role]) {
12245 element.setAttribute("role
", PDF_ROLE_TO_HTML_ROLE[role]);
12249 this._setAttributes(node, element);
12251 if (node.children) {
12252 if (node.children.length === 1 && "id
" in node.children[0]) {
12253 this._setAttributes(node.children[0], element);
12255 for (const kid of node.children) {
12256 element.appendChild(this._walk(kid));
12266 exports.StructTreeLayerBuilder = StructTreeLayerBuilder;
12268 class DefaultStructTreeLayerFactory {
12269 createStructTreeLayerBuilder(pdfPage) {
12270 return new StructTreeLayerBuilder({
12277 exports.DefaultStructTreeLayerFactory = DefaultStructTreeLayerFactory;
12281 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
12285 Object.defineProperty(exports, "__esModule
", ({
12288 exports.TextLayerBuilder = exports.DefaultTextLayerFactory = void 0;
12290 var _pdfjsLib = __webpack_require__(5);
12292 const EXPAND_DIVS_TIMEOUT = 300;
12294 class TextLayerBuilder {
12300 findController = null,
12301 enhanceTextSelection = false
12303 this.textLayerDiv = textLayerDiv;
12304 this.eventBus = eventBus;
12305 this.textContent = null;
12306 this.textContentItemsStr = [];
12307 this.textContentStream = null;
12308 this.renderingDone = false;
12309 this.pageIdx = pageIndex;
12310 this.pageNumber = this.pageIdx + 1;
12312 this.viewport = viewport;
12313 this.textDivs = [];
12314 this.findController = findController;
12315 this.textLayerRenderTask = null;
12316 this.enhanceTextSelection = enhanceTextSelection;
12317 this._onUpdateTextLayerMatches = null;
12322 _finishRendering() {
12323 this.renderingDone = true;
12325 if (!this.enhanceTextSelection) {
12326 const endOfContent = document.createElement("div
");
12327 endOfContent.className = "endOfContent
";
12328 this.textLayerDiv.appendChild(endOfContent);
12331 this.eventBus.dispatch("textlayerrendered
", {
12333 pageNumber: this.pageNumber,
12334 numTextDivs: this.textDivs.length
12338 render(timeout = 0) {
12339 if (!(this.textContent || this.textContentStream) || this.renderingDone) {
12344 this.textDivs = [];
12345 const textLayerFrag = document.createDocumentFragment();
12346 this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
12347 textContent: this.textContent,
12348 textContentStream: this.textContentStream,
12349 container: textLayerFrag,
12350 viewport: this.viewport,
12351 textDivs: this.textDivs,
12352 textContentItemsStr: this.textContentItemsStr,
12354 enhanceTextSelection: this.enhanceTextSelection
12356 this.textLayerRenderTask.promise.then(() => {
12357 this.textLayerDiv.appendChild(textLayerFrag);
12359 this._finishRendering();
12361 this._updateMatches();
12362 }, function (reason) {});
12364 if (!this._onUpdateTextLayerMatches) {
12365 this._onUpdateTextLayerMatches = evt => {
12366 if (evt.pageIndex === this.pageIdx || evt.pageIndex === -1) {
12367 this._updateMatches();
12371 this.eventBus._on("updatetextlayermatches
", this._onUpdateTextLayerMatches);
12376 if (this.textLayerRenderTask) {
12377 this.textLayerRenderTask.cancel();
12378 this.textLayerRenderTask = null;
12381 if (this._onUpdateTextLayerMatches) {
12382 this.eventBus._off("updatetextlayermatches
", this._onUpdateTextLayerMatches);
12384 this._onUpdateTextLayerMatches = null;
12388 setTextContentStream(readableStream) {
12390 this.textContentStream = readableStream;
12393 setTextContent(textContent) {
12395 this.textContent = textContent;
12398 _convertMatches(matches, matchesLength) {
12404 textContentItemsStr
12408 const end = textContentItemsStr.length - 1;
12411 for (let m = 0, mm = matches.length; m < mm; m++) {
12412 let matchIdx = matches[m];
12414 while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
12415 iIndex += textContentItemsStr[i].length;
12419 if (i === textContentItemsStr.length) {
12420 console.error("Could not find a matching mapping
");
12426 offset: matchIdx - iIndex
12429 matchIdx += matchesLength[m];
12431 while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
12432 iIndex += textContentItemsStr[i].length;
12438 offset: matchIdx - iIndex
12440 result.push(match);
12446 _renderMatches(matches) {
12447 if (matches.length === 0) {
12454 textContentItemsStr,
12457 const isSelectedPage = pageIdx === findController.selected.pageIdx;
12458 const selectedMatchIdx = findController.selected.matchIdx;
12459 const highlightAll = findController.state.highlightAll;
12460 let prevEnd = null;
12466 function beginText(begin, className) {
12467 const divIdx = begin.divIdx;
12468 textDivs[divIdx].textContent = "";
12469 return appendTextToDiv(divIdx, 0, begin.offset, className);
12472 function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
12473 const div = textDivs[divIdx];
12474 const content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
12475 const node = document.createTextNode(content);
12478 const span = document.createElement("span
");
12479 span.className = `${className} appended`;
12480 span.appendChild(node);
12481 div.appendChild(span);
12482 return className.includes("selected
") ? span.offsetLeft : 0;
12485 div.appendChild(node);
12489 let i0 = selectedMatchIdx,
12492 if (highlightAll) {
12494 i1 = matches.length;
12495 } else if (!isSelectedPage) {
12499 for (let i = i0; i < i1; i++) {
12500 const match = matches[i];
12501 const begin = match.begin;
12502 const end = match.end;
12503 const isSelected = isSelectedPage && i === selectedMatchIdx;
12504 const highlightSuffix = isSelected ? " selected
" : "";
12505 let selectedLeft = 0;
12507 if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
12508 if (prevEnd !== null) {
12509 appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
12514 appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
12517 if (begin.divIdx === end.divIdx) {
12518 selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight
" + highlightSuffix);
12520 selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin
" + highlightSuffix);
12522 for (let n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
12523 textDivs[n0].className = "highlight middle
" + highlightSuffix;
12526 beginText(end, "highlight end
" + highlightSuffix);
12532 findController.scrollMatchIntoView({
12533 element: textDivs[begin.divIdx],
12535 pageIndex: pageIdx,
12536 matchIndex: selectedMatchIdx
12542 appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
12547 if (!this.renderingDone) {
12555 textContentItemsStr,
12558 let clearedUntilDivIdx = -1;
12560 for (let i = 0, ii = matches.length; i < ii; i++) {
12561 const match = matches[i];
12562 const begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
12564 for (let n = begin, end = match.end.divIdx; n <= end; n++) {
12565 const div = textDivs[n];
12566 div.textContent = textContentItemsStr[n];
12567 div.className = "";
12570 clearedUntilDivIdx = match.end.divIdx + 1;
12573 if (!findController?.highlightMatches) {
12577 const pageMatches = findController.pageMatches[pageIdx] || null;
12578 const pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
12579 this.matches = this._convertMatches(pageMatches, pageMatchesLength);
12581 this._renderMatches(this.matches);
12585 const div = this.textLayerDiv;
12586 let expandDivsTimer = null;
12587 div.addEventListener("mousedown
", evt => {
12588 if (this.enhanceTextSelection && this.textLayerRenderTask) {
12589 this.textLayerRenderTask.expandTextDivs(true);
12591 if (expandDivsTimer) {
12592 clearTimeout(expandDivsTimer);
12593 expandDivsTimer = null;
12599 const end = div.querySelector(".endOfContent
");
12605 let adjustTop = evt.target !== div;
12606 adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue("-moz
-user
-select
") !== "none
";
12609 const divBounds = div.getBoundingClientRect();
12610 const r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
12611 end.style.top = (r * 100).toFixed(2) + "%";
12614 end.classList.add("active
");
12616 div.addEventListener("mouseup
", () => {
12617 if (this.enhanceTextSelection && this.textLayerRenderTask) {
12618 expandDivsTimer = setTimeout(() => {
12619 if (this.textLayerRenderTask) {
12620 this.textLayerRenderTask.expandTextDivs(false);
12623 expandDivsTimer = null;
12624 }, EXPAND_DIVS_TIMEOUT);
12628 const end = div.querySelector(".endOfContent
");
12634 end.style.top = "";
12635 end.classList.remove("active
");
12641 exports.TextLayerBuilder = TextLayerBuilder;
12643 class DefaultTextLayerFactory {
12644 createTextLayerBuilder(textLayerDiv, pageIndex, viewport, enhanceTextSelection = false, eventBus) {
12645 return new TextLayerBuilder({
12649 enhanceTextSelection,
12656 exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
12660 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
12664 Object.defineProperty(exports, "__esModule
", ({
12667 exports.XfaLayerBuilder = exports.DefaultXfaLayerFactory = void 0;
12669 var _pdfjsLib = __webpack_require__(5);
12671 class XfaLayerBuilder {
12678 this.pageDiv = pageDiv;
12679 this.pdfPage = pdfPage;
12680 this.xfaHtml = xfaHtml;
12681 this.annotationStorage = annotationStorage;
12683 this._cancelled = false;
12686 render(viewport, intent = "display
") {
12687 if (intent === "print
") {
12688 const parameters = {
12689 viewport: viewport.clone({
12695 annotationStorage: this.annotationStorage,
12698 const div = document.createElement("div
");
12699 this.pageDiv.appendChild(div);
12700 parameters.div = div;
12702 _pdfjsLib.XfaLayer.render(parameters);
12704 return Promise.resolve();
12707 return this.pdfPage.getXfa().then(xfa => {
12708 if (this._cancelled) {
12712 const parameters = {
12713 viewport: viewport.clone({
12718 page: this.pdfPage,
12719 annotationStorage: this.annotationStorage,
12724 _pdfjsLib.XfaLayer.update(parameters);
12726 this.div = document.createElement("div
");
12727 this.pageDiv.appendChild(this.div);
12728 parameters.div = this.div;
12730 _pdfjsLib.XfaLayer.render(parameters);
12732 }).catch(error => {
12733 console.error(error);
12738 this._cancelled = true;
12746 this.div.hidden = true;
12751 exports.XfaLayerBuilder = XfaLayerBuilder;
12753 class DefaultXfaLayerFactory {
12754 createXfaLayerBuilder(pageDiv, pdfPage, annotationStorage = null, xfaHtml = null) {
12755 return new XfaLayerBuilder({
12765 exports.DefaultXfaLayerFactory = DefaultXfaLayerFactory;
12769 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
12773 Object.defineProperty(exports, "__esModule
", ({
12776 exports.SecondaryToolbar = void 0;
12778 var _ui_utils = __webpack_require__(4);
12780 var _pdf_cursor_tools = __webpack_require__(6);
12782 var _pdf_single_page_viewer = __webpack_require__(36);
12784 class SecondaryToolbar {
12785 constructor(options, mainContainer, eventBus) {
12786 this.toolbar = options.toolbar;
12787 this.toggleButton = options.toggleButton;
12788 this.toolbarButtonContainer = options.toolbarButtonContainer;
12790 element: options.presentationModeButton,
12791 eventName: "presentationmode
",
12794 element: options.openFileButton,
12795 eventName: "openfile
",
12798 element: options.printButton,
12799 eventName: "print
",
12802 element: options.downloadButton,
12803 eventName: "download
",
12806 element: options.viewBookmarkButton,
12810 element: options.firstPageButton,
12811 eventName: "firstpage
",
12814 element: options.lastPageButton,
12815 eventName: "lastpage
",
12818 element: options.pageRotateCwButton,
12819 eventName: "rotatecw
",
12822 element: options.pageRotateCcwButton,
12823 eventName: "rotateccw
",
12826 element: options.cursorSelectToolButton,
12827 eventName: "switchcursortool
",
12829 tool: _pdf_cursor_tools.CursorTool.SELECT
12833 element: options.cursorHandToolButton,
12834 eventName: "switchcursortool
",
12836 tool: _pdf_cursor_tools.CursorTool.HAND
12840 element: options.scrollVerticalButton,
12841 eventName: "switchscrollmode
",
12843 mode: _ui_utils.ScrollMode.VERTICAL
12847 element: options.scrollHorizontalButton,
12848 eventName: "switchscrollmode
",
12850 mode: _ui_utils.ScrollMode.HORIZONTAL
12854 element: options.scrollWrappedButton,
12855 eventName: "switchscrollmode
",
12857 mode: _ui_utils.ScrollMode.WRAPPED
12861 element: options.spreadNoneButton,
12862 eventName: "switchspreadmode
",
12864 mode: _ui_utils.SpreadMode.NONE
12868 element: options.spreadOddButton,
12869 eventName: "switchspreadmode
",
12871 mode: _ui_utils.SpreadMode.ODD
12875 element: options.spreadEvenButton,
12876 eventName: "switchspreadmode
",
12878 mode: _ui_utils.SpreadMode.EVEN
12882 element: options.documentPropertiesButton,
12883 eventName: "documentproperties
",
12887 firstPage: options.firstPageButton,
12888 lastPage: options.lastPageButton,
12889 pageRotateCw: options.pageRotateCwButton,
12890 pageRotateCcw: options.pageRotateCcwButton
12892 this.mainContainer = mainContainer;
12893 this.eventBus = eventBus;
12894 this.opened = false;
12895 this.containerHeight = null;
12896 this.previousContainerHeight = null;
12899 this._bindClickListeners();
12901 this._bindCursorToolsListener(options);
12903 this._bindScrollModeListener(options);
12905 this._bindSpreadModeListener(options);
12907 this.eventBus._on("resize
", this._setMaxHeight.bind(this));
12909 this.eventBus._on("baseviewerinit
", evt => {
12910 if (evt.source instanceof _pdf_single_page_viewer.PDFSinglePageViewer) {
12911 this.toolbarButtonContainer.classList.add("hiddenScrollModeButtons
", "hiddenSpreadModeButtons
");
12913 this.toolbarButtonContainer.classList.remove("hiddenScrollModeButtons
", "hiddenSpreadModeButtons
");
12919 return this.opened;
12922 setPageNumber(pageNumber) {
12923 this.pageNumber = pageNumber;
12925 this._updateUIState();
12928 setPagesCount(pagesCount) {
12929 this.pagesCount = pagesCount;
12931 this._updateUIState();
12935 this.pageNumber = 0;
12936 this.pagesCount = 0;
12938 this._updateUIState();
12940 this.eventBus.dispatch("secondarytoolbarreset
", {
12946 this.items.firstPage.disabled = this.pageNumber <= 1;
12947 this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
12948 this.items.pageRotateCw.disabled = this.pagesCount === 0;
12949 this.items.pageRotateCcw.disabled = this.pagesCount === 0;
12952 _bindClickListeners() {
12953 this.toggleButton.addEventListener("click
", this.toggle.bind(this));
12960 } of this.buttons) {
12961 element.addEventListener("click
", evt => {
12962 if (eventName !== null) {
12967 for (const property in eventDetails) {
12968 details[property] = eventDetails[property];
12971 this.eventBus.dispatch(eventName, details);
12981 _bindCursorToolsListener(buttons) {
12982 this.eventBus._on("cursortoolchanged
", function ({
12985 buttons.cursorSelectToolButton.classList.toggle("toggled
", tool === _pdf_cursor_tools.CursorTool.SELECT);
12986 buttons.cursorHandToolButton.classList.toggle("toggled
", tool === _pdf_cursor_tools.CursorTool.HAND);
12990 _bindScrollModeListener(buttons) {
12991 function scrollModeChanged({
12994 buttons.scrollVerticalButton.classList.toggle("toggled
", mode === _ui_utils.ScrollMode.VERTICAL);
12995 buttons.scrollHorizontalButton.classList.toggle("toggled
", mode === _ui_utils.ScrollMode.HORIZONTAL);
12996 buttons.scrollWrappedButton.classList.toggle("toggled
", mode === _ui_utils.ScrollMode.WRAPPED);
12997 const isScrollModeHorizontal = mode === _ui_utils.ScrollMode.HORIZONTAL;
12998 buttons.spreadNoneButton.disabled = isScrollModeHorizontal;
12999 buttons.spreadOddButton.disabled = isScrollModeHorizontal;
13000 buttons.spreadEvenButton.disabled = isScrollModeHorizontal;
13003 this.eventBus._on("scrollmodechanged
", scrollModeChanged);
13005 this.eventBus._on("secondarytoolbarreset
", evt => {
13006 if (evt.source === this) {
13007 scrollModeChanged({
13008 mode: _ui_utils.ScrollMode.VERTICAL
13014 _bindSpreadModeListener(buttons) {
13015 function spreadModeChanged({
13018 buttons.spreadNoneButton.classList.toggle("toggled
", mode === _ui_utils.SpreadMode.NONE);
13019 buttons.spreadOddButton.classList.toggle("toggled
", mode === _ui_utils.SpreadMode.ODD);
13020 buttons.spreadEvenButton.classList.toggle("toggled
", mode === _ui_utils.SpreadMode.EVEN);
13023 this.eventBus._on("spreadmodechanged
", spreadModeChanged);
13025 this.eventBus._on("secondarytoolbarreset
", evt => {
13026 if (evt.source === this) {
13027 spreadModeChanged({
13028 mode: _ui_utils.SpreadMode.NONE
13039 this.opened = true;
13041 this._setMaxHeight();
13043 this.toggleButton.classList.add("toggled
");
13044 this.toggleButton.setAttribute("aria
-expanded
", "true");
13045 this.toolbar.classList.remove("hidden
");
13049 if (!this.opened) {
13053 this.opened = false;
13054 this.toolbar.classList.add("hidden
");
13055 this.toggleButton.classList.remove("toggled
");
13056 this.toggleButton.setAttribute("aria
-expanded
", "false");
13068 if (!this.opened) {
13072 this.containerHeight = this.mainContainer.clientHeight;
13074 if (this.containerHeight === this.previousContainerHeight) {
13078 this.toolbarButtonContainer.style.maxHeight = `${this.containerHeight - _ui_utils.SCROLLBAR_PADDING}px`;
13079 this.previousContainerHeight = this.containerHeight;
13084 exports.SecondaryToolbar = SecondaryToolbar;
13088 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
13092 Object.defineProperty(exports, "__esModule
", ({
13095 exports.PDFSinglePageViewer = void 0;
13097 var _base_viewer = __webpack_require__(28);
13099 var _pdfjsLib = __webpack_require__(5);
13101 class PDFSinglePageViewer extends _base_viewer.BaseViewer {
13102 constructor(options) {
13105 this.eventBus._on("pagesinit
", evt => {
13106 this._ensurePageViewVisible();
13110 get _viewerElement() {
13111 return (0, _pdfjsLib.shadow)(this, "_viewerElement
", this._shadowViewer);
13114 get _pageWidthScaleFactor() {
13119 super._resetView();
13121 this._previousPageNumber = 1;
13122 this._shadowViewer = document.createDocumentFragment();
13123 this._updateScrollDown = null;
13126 _ensurePageViewVisible() {
13127 const pageView = this._pages[this._currentPageNumber - 1];
13128 const previousPageView = this._pages[this._previousPageNumber - 1];
13129 const viewerNodes = this.viewer.childNodes;
13131 switch (viewerNodes.length) {
13133 this.viewer.appendChild(pageView.div);
13137 if (viewerNodes[0] !== previousPageView.div) {
13138 throw new Error("_ensurePageViewVisible
: Unexpected previously visible page
.");
13141 if (pageView === previousPageView) {
13145 this._shadowViewer.appendChild(previousPageView.div);
13147 this.viewer.appendChild(pageView.div);
13148 this.container.scrollTop = 0;
13152 throw new Error("_ensurePageViewVisible
: Only one page should be visible at a time
.");
13155 this._previousPageNumber = this._currentPageNumber;
13159 if (this._updateScrollDown) {
13160 this._updateScrollDown();
13163 super._scrollUpdate();
13172 this._setCurrentPageNumber(pageNumber);
13175 const scrolledDown = this._currentPageNumber >= this._previousPageNumber;
13177 this._ensurePageViewVisible();
13181 super._scrollIntoView({
13187 this._updateScrollDown = () => {
13188 this.scroll.down = scrolledDown;
13189 this._updateScrollDown = null;
13193 _getVisiblePages() {
13194 return this._getCurrentVisiblePage();
13197 _updateHelper(visiblePages) {}
13199 get _isScrollModeHorizontal() {
13200 return (0, _pdfjsLib.shadow)(this, "_isScrollModeHorizontal
", false);
13203 _updateScrollMode() {}
13205 _updateSpreadMode() {}
13207 _getPageAdvance() {
13213 exports.PDFSinglePageViewer = PDFSinglePageViewer;
13217 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
13221 Object.defineProperty(exports, "__esModule
", ({
13224 exports.Toolbar = void 0;
13226 var _ui_utils = __webpack_require__(4);
13228 const PAGE_NUMBER_LOADING_INDICATOR = "visiblePageIsLoading
";
13229 const SCALE_SELECT_CONTAINER_WIDTH = 140;
13230 const SCALE_SELECT_WIDTH = 162;
13233 constructor(options, eventBus, l10n) {
13234 this.toolbar = options.container;
13235 this.eventBus = eventBus;
13238 element: options.previous,
13239 eventName: "previouspage
"
13241 element: options.next,
13242 eventName: "nextpage
"
13244 element: options.zoomIn,
13245 eventName: "zoomin
"
13247 element: options.zoomOut,
13248 eventName: "zoomout
"
13250 element: options.openFile,
13251 eventName: "openfile
"
13253 element: options.print,
13256 element: options.presentationModeButton,
13257 eventName: "presentationmode
"
13259 element: options.download,
13260 eventName: "download
"
13262 element: options.viewBookmark,
13266 numPages: options.numPages,
13267 pageNumber: options.pageNumber,
13268 scaleSelectContainer: options.scaleSelectContainer,
13269 scaleSelect: options.scaleSelect,
13270 customScaleOption: options.customScaleOption,
13271 previous: options.previous,
13272 next: options.next,
13273 zoomIn: options.zoomIn,
13274 zoomOut: options.zoomOut
13276 this._wasLocalized = false;
13279 this._bindListeners();
13282 setPageNumber(pageNumber, pageLabel) {
13283 this.pageNumber = pageNumber;
13284 this.pageLabel = pageLabel;
13286 this._updateUIState(false);
13289 setPagesCount(pagesCount, hasPageLabels) {
13290 this.pagesCount = pagesCount;
13291 this.hasPageLabels = hasPageLabels;
13293 this._updateUIState(true);
13296 setPageScale(pageScaleValue, pageScale) {
13297 this.pageScaleValue = (pageScaleValue || pageScale).toString();
13298 this.pageScale = pageScale;
13300 this._updateUIState(false);
13304 this.pageNumber = 0;
13305 this.pageLabel = null;
13306 this.hasPageLabels = false;
13307 this.pagesCount = 0;
13308 this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
13309 this.pageScale = _ui_utils.DEFAULT_SCALE;
13311 this._updateUIState(true);
13313 this.updateLoadingIndicatorState();
13326 } of this.buttons) {
13327 element.addEventListener("click
", evt => {
13328 if (eventName !== null) {
13329 this.eventBus.dispatch(eventName, {
13336 pageNumber.addEventListener("click
", function () {
13339 pageNumber.addEventListener("change
", function () {
13340 self.eventBus.dispatch("pagenumberchanged
", {
13345 scaleSelect.addEventListener("change
", function () {
13346 if (this.value === "custom
") {
13350 self.eventBus.dispatch("scalechanged
", {
13355 scaleSelect.addEventListener("click
", function (evt) {
13356 const target = evt.target;
13358 if (this.value === self.pageScaleValue && target.tagName.toUpperCase() === "OPTION
") {
13362 scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
13364 this.eventBus._on("localized
", () => {
13365 this._wasLocalized = true;
13367 this._adjustScaleWidth();
13369 this._updateUIState(true);
13373 _updateUIState(resetNumPages = false) {
13374 if (!this._wasLocalized) {
13386 if (resetNumPages) {
13387 if (this.hasPageLabels) {
13388 items.pageNumber.type = "text
";
13390 items.pageNumber.type = "number
";
13391 this.l10n.get("of_pages
", {
13394 items.numPages.textContent = msg;
13398 items.pageNumber.max = pagesCount;
13401 if (this.hasPageLabels) {
13402 items.pageNumber.value = this.pageLabel;
13403 this.l10n.get("page_of_pages
", {
13407 items.numPages.textContent = msg;
13410 items.pageNumber.value = pageNumber;
13413 items.previous.disabled = pageNumber <= 1;
13414 items.next.disabled = pageNumber >= pagesCount;
13415 items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
13416 items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
13417 this.l10n.get("page_scale_percent
", {
13418 scale: Math.round(pageScale * 10000) / 100
13420 let predefinedValueFound = false;
13422 for (const option of items.scaleSelect.options) {
13423 if (option.value !== pageScaleValue) {
13424 option.selected = false;
13428 option.selected = true;
13429 predefinedValueFound = true;
13432 if (!predefinedValueFound) {
13433 items.customScaleOption.textContent = msg;
13434 items.customScaleOption.selected = true;
13439 updateLoadingIndicatorState(loading = false) {
13440 const pageNumberInput = this.items.pageNumber;
13441 pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
13444 async _adjustScaleWidth() {
13449 const predefinedValuesPromise = Promise.all([l10n.get("page_scale_auto
"), l10n.get("page_scale_actual
"), l10n.get("page_scale_fit
"), l10n.get("page_scale_width
")]);
13450 let canvas = document.createElement("canvas
");
13451 canvas.mozOpaque = true;
13452 let ctx = canvas.getContext("2d
", {
13455 await _ui_utils.animationStarted;
13459 } = getComputedStyle(items.scaleSelect);
13460 ctx.font = `${fontSize} ${fontFamily}`;
13463 for (const predefinedValue of await predefinedValuesPromise) {
13466 } = ctx.measureText(predefinedValue);
13468 if (width > maxWidth) {
13473 const overflow = SCALE_SELECT_WIDTH - SCALE_SELECT_CONTAINER_WIDTH;
13474 maxWidth += 2 * overflow;
13476 if (maxWidth > SCALE_SELECT_CONTAINER_WIDTH) {
13477 items.scaleSelect.style.width = `${maxWidth + overflow}px`;
13478 items.scaleSelectContainer.style.width = `${maxWidth}px`;
13483 canvas = ctx = null;
13488 exports.Toolbar = Toolbar;
13492 /***/ ((__unused_webpack_module, exports) => {
13496 Object.defineProperty(exports, "__esModule
", ({
13499 exports.ViewHistory = void 0;
13500 const DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
13502 class ViewHistory {
13503 constructor(fingerprint, cacheSize = DEFAULT_VIEW_HISTORY_CACHE_SIZE) {
13504 this.fingerprint = fingerprint;
13505 this.cacheSize = cacheSize;
13506 this._initializedPromise = this._readFromStorage().then(databaseStr => {
13507 const database = JSON.parse(databaseStr || "{}");
13510 if (!Array.isArray(database.files)) {
13511 database.files = [];
13513 while (database.files.length >= this.cacheSize) {
13514 database.files.shift();
13517 for (let i = 0, ii = database.files.length; i < ii; i++) {
13518 const branch = database.files[i];
13520 if (branch.fingerprint === this.fingerprint) {
13527 if (index === -1) {
13528 index = database.files.push({
13529 fingerprint: this.fingerprint
13533 this.file = database.files[index];
13534 this.database = database;
13538 async _writeToStorage() {
13539 const databaseStr = JSON.stringify(this.database);
13540 localStorage.setItem("pdfjs
.history
", databaseStr);
13543 async _readFromStorage() {
13544 return localStorage.getItem("pdfjs
.history
");
13547 async set(name, val) {
13548 await this._initializedPromise;
13549 this.file[name] = val;
13550 return this._writeToStorage();
13553 async setMultiple(properties) {
13554 await this._initializedPromise;
13556 for (const name in properties) {
13557 this.file[name] = properties[name];
13560 return this._writeToStorage();
13563 async get(name, defaultValue) {
13564 await this._initializedPromise;
13565 const val = this.file[name];
13566 return val !== undefined ? val : defaultValue;
13569 async getMultiple(properties) {
13570 await this._initializedPromise;
13571 const values = Object.create(null);
13573 for (const name in properties) {
13574 const val = this.file[name];
13575 values[name] = val !== undefined ? val : properties[name];
13583 exports.ViewHistory = ViewHistory;
13587 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
13591 Object.defineProperty(exports, "__esModule
", ({
13594 exports.GenericCom = void 0;
13596 var _app = __webpack_require__(3);
13598 var _preferences = __webpack_require__(40);
13600 var _download_manager = __webpack_require__(41);
13602 var _genericl10n = __webpack_require__(42);
13604 var _generic_scripting = __webpack_require__(44);
13607 const GenericCom = {};
13608 exports.GenericCom = GenericCom;
13610 class GenericPreferences extends _preferences.BasePreferences {
13611 async _writeToStorage(prefObj) {
13612 localStorage.setItem("pdfjs
.preferences
", JSON.stringify(prefObj));
13615 async _readFromStorage(prefObj) {
13616 return JSON.parse(localStorage.getItem("pdfjs
.preferences
"));
13621 class GenericExternalServices extends _app.DefaultExternalServices {
13622 static createDownloadManager(options) {
13623 return new _download_manager.DownloadManager();
13626 static createPreferences() {
13627 return new GenericPreferences();
13630 static createL10n({
13633 return new _genericl10n.GenericL10n(locale);
13636 static createScripting({
13639 return new _generic_scripting.GenericScripting(sandboxBundleSrc);
13644 _app.PDFViewerApplication.externalServices = GenericExternalServices;
13648 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
13652 Object.defineProperty(exports, "__esModule
", ({
13655 exports.BasePreferences = void 0;
13657 var _app_options = __webpack_require__(1);
13659 class BasePreferences {
13661 if (this.constructor === BasePreferences) {
13662 throw new Error("Cannot initialize BasePreferences
.");
13665 Object.defineProperty(this, "defaults
", {
13666 value: Object.freeze({
13667 "cursorToolOnLoad
": 0,
13668 "defaultZoomValue
": "",
13669 "disablePageLabels
": false,
13670 "enablePermissions
": false,
13671 "enablePrintAutoRotate
": true,
13672 "enableScripting
": true,
13673 "externalLinkTarget
": 0,
13674 "historyUpdateUrl
": false,
13675 "ignoreDestinationZoom
": false,
13676 "pdfBugEnabled
": false,
13677 "renderer
": "canvas
",
13678 "renderInteractiveForms
": true,
13679 "sidebarViewOnLoad
": -1,
13680 "scrollModeOnLoad
": -1,
13681 "spreadModeOnLoad
": -1,
13682 "textLayerMode
": 1,
13683 "useOnlyCssZoom
": false,
13684 "viewerCssTheme
": 0,
13686 "disableAutoFetch
": false,
13687 "disableFontFace
": false,
13688 "disableRange
": false,
13689 "disableStream
": false,
13694 configurable: false
13696 this.prefs = Object.create(null);
13697 this._initializedPromise = this._readFromStorage(this.defaults).then(prefs => {
13698 for (const name in this.defaults) {
13699 const prefValue = prefs?.[name];
13701 if (typeof prefValue === typeof this.defaults[name]) {
13702 this.prefs[name] = prefValue;
13708 async _writeToStorage(prefObj) {
13709 throw new Error("Not implemented
: _writeToStorage
");
13712 async _readFromStorage(prefObj) {
13713 throw new Error("Not implemented
: _readFromStorage
");
13717 await this._initializedPromise;
13718 this.prefs = Object.create(null);
13719 return this._writeToStorage(this.defaults);
13722 async set(name, value) {
13723 await this._initializedPromise;
13724 const defaultValue = this.defaults[name];
13726 if (defaultValue === undefined) {
13727 throw new Error(`Set preference: "${name}
" is undefined.`);
13728 } else if (value === undefined) {
13729 throw new Error("Set preference
: no value is specified
.");
13732 const valueType = typeof value;
13733 const defaultType = typeof defaultValue;
13735 if (valueType !== defaultType) {
13736 if (valueType === "number
" && defaultType === "string
") {
13737 value = value.toString();
13739 throw new Error(`Set preference: "${value}
" is a ${valueType}, expected a ${defaultType}.`);
13742 if (valueType === "number
" && !Number.isInteger(value)) {
13743 throw new Error(`Set preference: "${value}
" must be an integer.`);
13747 this.prefs[name] = value;
13748 return this._writeToStorage(this.prefs);
13752 await this._initializedPromise;
13753 const defaultValue = this.defaults[name],
13754 prefValue = this.prefs[name];
13756 if (defaultValue === undefined) {
13757 throw new Error(`Get preference: "${name}
" is undefined.`);
13760 return prefValue !== undefined ? prefValue : defaultValue;
13764 await this._initializedPromise;
13765 const obj = Object.create(null);
13767 for (const name in this.defaults) {
13768 const prefValue = this.prefs[name];
13769 obj[name] = prefValue !== undefined ? prefValue : this.defaults[name];
13777 exports.BasePreferences = BasePreferences;
13781 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
13785 Object.defineProperty(exports, "__esModule
", ({
13788 exports.DownloadManager = void 0;
13790 var _pdfjsLib = __webpack_require__(5);
13792 var _viewer_compatibility = __webpack_require__(2);
13796 function download(blobUrl, filename) {
13797 const a = document.createElement("a
");
13800 throw new Error('DownloadManager: "a
.click()" is not supported.');
13804 a.target = "_parent
";
13806 if ("download
" in a) {
13807 a.download = filename;
13810 (document.body || document.documentElement).appendChild(a);
13815 class DownloadManager {
13817 this._openBlobUrls = new WeakMap();
13820 downloadUrl(url, filename) {
13821 if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, "http
://example.com")) {
13825 download(url
+ "#pdfjs.action=download", filename
);
13828 downloadData(data
, filename
, contentType
) {
13829 const blobUrl
= (0, _pdfjsLib
.createObjectURL
)(data
, contentType
, _viewer_compatibility
.viewerCompatibilityParams
.disableCreateObjectURL
);
13830 download(blobUrl
, filename
);
13833 openOrDownloadData(element
, data
, filename
) {
13834 const isPdfData
= (0, _pdfjsLib
.isPdfFile
)(filename
);
13835 const contentType
= isPdfData
? "application/pdf" : "";
13837 if (isPdfData
&& !_viewer_compatibility
.viewerCompatibilityParams
.disableCreateObjectURL
) {
13838 let blobUrl
= this._openBlobUrls
.get(element
);
13841 blobUrl
= URL
.createObjectURL(new Blob([data
], {
13845 this._openBlobUrls
.set(element
, blobUrl
);
13849 viewerUrl
= "?file=" + encodeURIComponent(blobUrl
+ "#" + filename
);
13852 window
.open(viewerUrl
);
13855 console
.error(`openOrDownloadData: ${ex}`);
13856 URL
.revokeObjectURL(blobUrl
);
13858 this._openBlobUrls
.delete(element
);
13862 this.downloadData(data
, filename
, contentType
);
13866 download(blob
, url
, filename
, sourceEventType
= "download") {
13867 if (_viewer_compatibility
.viewerCompatibilityParams
.disableCreateObjectURL
) {
13868 this.downloadUrl(url
, filename
);
13872 const blobUrl
= URL
.createObjectURL(blob
);
13873 download(blobUrl
, filename
);
13878 exports
.DownloadManager
= DownloadManager
;
13882 /***/ ((__unused_webpack_module
, exports
, __webpack_require__
) => {
13886 Object
.defineProperty(exports
, "__esModule", ({
13889 exports
.GenericL10n
= void 0;
13891 __webpack_require__(43);
13893 var _l10n_utils
= __webpack_require__(30);
13895 const webL10n
= document
.webL10n
;
13897 class GenericL10n
{
13898 constructor(lang
) {
13900 this._ready
= new Promise((resolve
, reject
) => {
13901 webL10n
.setLanguage((0, _l10n_utils
.fixupLangCode
)(lang
), () => {
13907 async
getLanguage() {
13908 const l10n
= await
this._ready
;
13909 return l10n
.getLanguage();
13912 async
getDirection() {
13913 const l10n
= await
this._ready
;
13914 return l10n
.getDirection();
13917 async
get(key
, args
= null, fallback
= (0, _l10n_utils
.getL10nFallback
)(key
, args
)) {
13918 const l10n
= await
this._ready
;
13919 return l10n
.get(key
, args
, fallback
);
13922 async
translate(element
) {
13923 const l10n
= await
this._ready
;
13924 return l10n
.translate(element
);
13929 exports
.GenericL10n
= GenericL10n
;
13937 document
.webL10n = function (window
, document
, undefined) {
13938 var gL10nData
= {};
13939 var gTextData
= '';
13940 var gTextProp
= 'textContent';
13941 var gLanguage
= '';
13943 var gReadyState
= 'loading';
13944 var gAsyncResourceLoading
= true;
13946 function getL10nResourceLinks() {
13947 return document
.querySelectorAll('link[type="application/l10n"]');
13950 function getL10nDictionary() {
13951 var script
= document
.querySelector('script[type="application/l10n"]');
13952 return script
? JSON
.parse(script
.innerHTML
) : null;
13955 function getTranslatableChildren(element
) {
13956 return element
? element
.querySelectorAll('*[data-l10n-id]') : [];
13959 function getL10nAttributes(element
) {
13960 if (!element
) return {};
13961 var l10nId
= element
.getAttribute('data-l10n-id');
13962 var l10nArgs
= element
.getAttribute('data-l10n-args');
13967 args
= JSON
.parse(l10nArgs
);
13969 console
.warn('could not parse arguments for #' + l10nId
);
13979 function xhrLoadText(url
, onSuccess
, onFailure
) {
13980 onSuccess
= onSuccess
|| function _onSuccess(data
) {};
13982 onFailure
= onFailure
|| function _onFailure() {};
13984 var xhr
= new XMLHttpRequest();
13985 xhr
.open('GET', url
, gAsyncResourceLoading
);
13987 if (xhr
.overrideMimeType
) {
13988 xhr
.overrideMimeType('text/plain; charset=utf-8');
13991 xhr
.onreadystatechange = function () {
13992 if (xhr
.readyState
== 4) {
13993 if (xhr
.status
== 200 || xhr
.status
=== 0) {
13994 onSuccess(xhr
.responseText
);
14001 xhr
.onerror
= onFailure
;
14002 xhr
.ontimeout
= onFailure
;
14011 function parseResource(href
, lang
, successCallback
, failureCallback
) {
14012 var baseURL
= href
.replace(/[^\/]*$/, '') || './';
14014 function evalString(text
) {
14015 if (text
.lastIndexOf('\\') < 0) return text
;
14016 return text
.replace(/\\\\/g, '\\').replace(/\\n
/g, '\n').replace(/\\r
/g, '\r').replace(/\\t
/g, '\t').replace(/\\b
/g, '\b').replace(/\\f
/g, '\f').replace(/\\{/g, '{').replace(/\\}/g, '}').replace(/\\"/g, '"').replace(/\\'/g
, "'");
14019 function parseProperties(text
, parsedPropertiesCallback
) {
14020 var dictionary
= {};
14021 var reBlank
= /^\s*|\s*$/;
14022 var reComment
= /^\s*#|^\s*$/;
14023 var reSection
= /^\s*\[(.*)\]\s*$/;
14024 var reImport
= /^\s*@import\s+url\((.*)\)\s*$/i;
14025 var reSplit
= /^([^=\s]*)\s*=\s*(.+)$/;
14027 function parseRawLines(rawText
, extendedSyntax
, parsedRawLinesCallback
) {
14028 var entries
= rawText
.replace(reBlank
, '').split(/[\r\n]+/);
14029 var currentLang
= '*';
14030 var genericLang
= lang
.split('-', 1)[0];
14031 var skipLang
= false;
14034 function nextEntry() {
14036 if (!entries
.length
) {
14037 parsedRawLinesCallback();
14041 var line
= entries
.shift();
14042 if (reComment
.test(line
)) continue;
14044 if (extendedSyntax
) {
14045 match
= reSection
.exec(line
);
14048 currentLang
= match
[1].toLowerCase();
14049 skipLang
= currentLang
!== '*' && currentLang
!== lang
&& currentLang
!== genericLang
;
14051 } else if (skipLang
) {
14055 match
= reImport
.exec(line
);
14058 loadImport(baseURL
+ match
[1], nextEntry
);
14063 var tmp
= line
.match(reSplit
);
14065 if (tmp
&& tmp
.length
== 3) {
14066 dictionary
[tmp
[1]] = evalString(tmp
[2]);
14074 function loadImport(url
, callback
) {
14075 xhrLoadText(url
, function (content
) {
14076 parseRawLines(content
, false, callback
);
14078 console
.warn(url
+ ' not found.');
14083 parseRawLines(text
, true, function () {
14084 parsedPropertiesCallback(dictionary
);
14088 xhrLoadText(href
, function (response
) {
14089 gTextData
+= response
;
14090 parseProperties(response
, function (data
) {
14091 for (var key
in data
) {
14094 index
= key
.lastIndexOf('.');
14097 id
= key
.substring(0, index
);
14098 prop
= key
.substring(index
+ 1);
14104 if (!gL10nData
[id
]) {
14105 gL10nData
[id
] = {};
14108 gL10nData
[id
][prop
] = data
[key
];
14111 if (successCallback
) {
14115 }, failureCallback
);
14118 function loadLocale(lang
, callback
) {
14120 lang
= lang
.toLowerCase();
14123 callback
= callback
|| function _callback() {};
14127 var langLinks
= getL10nResourceLinks();
14128 var langCount
= langLinks
.length
;
14130 if (langCount
=== 0) {
14131 var dict
= getL10nDictionary();
14133 if (dict
&& dict
.locales
&& dict
.default_locale
) {
14134 console
.log('using the embedded JSON directory, early way out');
14135 gL10nData
= dict
.locales
[lang
];
14138 var defaultLocale
= dict
.default_locale
.toLowerCase();
14140 for (var anyCaseLang
in dict
.locales
) {
14141 anyCaseLang
= anyCaseLang
.toLowerCase();
14143 if (anyCaseLang
=== lang
) {
14144 gL10nData
= dict
.locales
[lang
];
14146 } else if (anyCaseLang
=== defaultLocale
) {
14147 gL10nData
= dict
.locales
[defaultLocale
];
14154 console
.log('no resource to load, early way out');
14157 gReadyState
= 'complete';
14161 var onResourceLoaded
= null;
14162 var gResourceCount
= 0;
14164 onResourceLoaded = function () {
14167 if (gResourceCount
>= langCount
) {
14169 gReadyState
= 'complete';
14173 function L10nResourceLink(link
) {
14174 var href
= link
.href
;
14176 this.load = function (lang
, callback
) {
14177 parseResource(href
, lang
, callback
, function () {
14178 console
.warn(href
+ ' not found.');
14179 console
.warn('"' + lang
+ '" resource not found');
14186 for (var i
= 0; i
< langCount
; i
++) {
14187 var resource
= new L10nResourceLink(langLinks
[i
]);
14188 resource
.load(lang
, onResourceLoaded
);
14198 function getPluralRules(lang
) {
14199 var locales2rules
= {
14372 function isIn(n
, list
) {
14373 return list
.indexOf(n
) !== -1;
14376 function isBetween(n
, start
, end
) {
14377 return start
<= n
&& n
<= end
;
14380 var pluralRules
= {
14381 '0': function (n
) {
14384 '1': function (n
) {
14385 if (isBetween(n
% 100, 3, 10)) return 'few';
14386 if (n
=== 0) return 'zero';
14387 if (isBetween(n
% 100, 11, 99)) return 'many';
14388 if (n
== 2) return 'two';
14389 if (n
== 1) return 'one';
14392 '2': function (n
) {
14393 if (n
!== 0 && n
% 10 === 0) return 'many';
14394 if (n
== 2) return 'two';
14395 if (n
== 1) return 'one';
14398 '3': function (n
) {
14399 if (n
== 1) return 'one';
14402 '4': function (n
) {
14403 if (isBetween(n
, 0, 1)) return 'one';
14406 '5': function (n
) {
14407 if (isBetween(n
, 0, 2) && n
!= 2) return 'one';
14410 '6': function (n
) {
14411 if (n
=== 0) return 'zero';
14412 if (n
% 10 == 1 && n
% 100 != 11) return 'one';
14415 '7': function (n
) {
14416 if (n
== 2) return 'two';
14417 if (n
== 1) return 'one';
14420 '8': function (n
) {
14421 if (isBetween(n
, 3, 6)) return 'few';
14422 if (isBetween(n
, 7, 10)) return 'many';
14423 if (n
== 2) return 'two';
14424 if (n
== 1) return 'one';
14427 '9': function (n
) {
14428 if (n
=== 0 || n
!= 1 && isBetween(n
% 100, 1, 19)) return 'few';
14429 if (n
== 1) return 'one';
14432 '10': function (n
) {
14433 if (isBetween(n
% 10, 2, 9) && !isBetween(n
% 100, 11, 19)) return 'few';
14434 if (n
% 10 == 1 && !isBetween(n
% 100, 11, 19)) return 'one';
14437 '11': function (n
) {
14438 if (isBetween(n
% 10, 2, 4) && !isBetween(n
% 100, 12, 14)) return 'few';
14439 if (n
% 10 === 0 || isBetween(n
% 10, 5, 9) || isBetween(n
% 100, 11, 14)) return 'many';
14440 if (n
% 10 == 1 && n
% 100 != 11) return 'one';
14443 '12': function (n
) {
14444 if (isBetween(n
, 2, 4)) return 'few';
14445 if (n
== 1) return 'one';
14448 '13': function (n
) {
14449 if (isBetween(n
% 10, 2, 4) && !isBetween(n
% 100, 12, 14)) return 'few';
14450 if (n
!= 1 && isBetween(n
% 10, 0, 1) || isBetween(n
% 10, 5, 9) || isBetween(n
% 100, 12, 14)) return 'many';
14451 if (n
== 1) return 'one';
14454 '14': function (n
) {
14455 if (isBetween(n
% 100, 3, 4)) return 'few';
14456 if (n
% 100 == 2) return 'two';
14457 if (n
% 100 == 1) return 'one';
14460 '15': function (n
) {
14461 if (n
=== 0 || isBetween(n
% 100, 2, 10)) return 'few';
14462 if (isBetween(n
% 100, 11, 19)) return 'many';
14463 if (n
== 1) return 'one';
14466 '16': function (n
) {
14467 if (n
% 10 == 1 && n
!= 11) return 'one';
14470 '17': function (n
) {
14471 if (n
== 3) return 'few';
14472 if (n
=== 0) return 'zero';
14473 if (n
== 6) return 'many';
14474 if (n
== 2) return 'two';
14475 if (n
== 1) return 'one';
14478 '18': function (n
) {
14479 if (n
=== 0) return 'zero';
14480 if (isBetween(n
, 0, 2) && n
!== 0 && n
!= 2) return 'one';
14483 '19': function (n
) {
14484 if (isBetween(n
, 2, 10)) return 'few';
14485 if (isBetween(n
, 0, 1)) return 'one';
14488 '20': function (n
) {
14489 if ((isBetween(n
% 10, 3, 4) || n
% 10 == 9) && !(isBetween(n
% 100, 10, 19) || isBetween(n
% 100, 70, 79) || isBetween(n
% 100, 90, 99))) return 'few';
14490 if (n
% 1000000 === 0 && n
!== 0) return 'many';
14491 if (n
% 10 == 2 && !isIn(n
% 100, [12, 72, 92])) return 'two';
14492 if (n
% 10 == 1 && !isIn(n
% 100, [11, 71, 91])) return 'one';
14495 '21': function (n
) {
14496 if (n
=== 0) return 'zero';
14497 if (n
== 1) return 'one';
14500 '22': function (n
) {
14501 if (isBetween(n
, 0, 1) || isBetween(n
, 11, 99)) return 'one';
14504 '23': function (n
) {
14505 if (isBetween(n
% 10, 1, 2) || n
% 20 === 0) return 'one';
14508 '24': function (n
) {
14509 if (isBetween(n
, 3, 10) || isBetween(n
, 13, 19)) return 'few';
14510 if (isIn(n
, [2, 12])) return 'two';
14511 if (isIn(n
, [1, 11])) return 'one';
14515 var index
= locales2rules
[lang
.replace(/-.*$/, '')];
14517 if (!(index
in pluralRules
)) {
14518 console
.warn('plural form unknown for [' + lang
+ ']');
14519 return function () {
14524 return pluralRules
[index
];
14527 gMacros
.plural = function (str
, param
, key
, prop
) {
14528 var n
= parseFloat(param
);
14529 if (isNaN(n
)) return str
;
14530 if (prop
!= gTextProp
) return str
;
14532 if (!gMacros
._pluralRules
) {
14533 gMacros
._pluralRules
= getPluralRules(gLanguage
);
14536 var index
= '[' + gMacros
._pluralRules(n
) + ']';
14538 if (n
=== 0 && key
+ '[zero]' in gL10nData
) {
14539 str
= gL10nData
[key
+ '[zero]'][prop
];
14540 } else if (n
== 1 && key
+ '[one]' in gL10nData
) {
14541 str
= gL10nData
[key
+ '[one]'][prop
];
14542 } else if (n
== 2 && key
+ '[two]' in gL10nData
) {
14543 str
= gL10nData
[key
+ '[two]'][prop
];
14544 } else if (key
+ index
in gL10nData
) {
14545 str
= gL10nData
[key
+ index
][prop
];
14546 } else if (key
+ '[other]' in gL10nData
) {
14547 str
= gL10nData
[key
+ '[other]'][prop
];
14553 function getL10nData(key
, args
, fallback
) {
14554 var data
= gL10nData
[key
];
14557 console
.warn('#' + key
+ ' is undefined.');
14568 for (var prop
in data
) {
14569 var str
= data
[prop
];
14570 str
= substIndexes(str
, args
, key
, prop
);
14571 str
= substArguments(str
, args
, key
);
14578 function substIndexes(str
, args
, key
, prop
) {
14579 var reIndex
= /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
14580 var reMatch
= reIndex
.exec(str
);
14581 if (!reMatch
|| !reMatch
.length
) return str
;
14582 var macroName
= reMatch
[1];
14583 var paramName
= reMatch
[2];
14586 if (args
&& paramName
in args
) {
14587 param
= args
[paramName
];
14588 } else if (paramName
in gL10nData
) {
14589 param
= gL10nData
[paramName
];
14592 if (macroName
in gMacros
) {
14593 var macro
= gMacros
[macroName
];
14594 str
= macro(str
, param
, key
, prop
);
14600 function substArguments(str
, args
, key
) {
14601 var reArgs
= /\{\{\s*(.+?)\s*\}\}/g;
14602 return str
.replace(reArgs
, function (matched_text
, arg
) {
14603 if (args
&& arg
in args
) {
14607 if (arg
in gL10nData
) {
14608 return gL10nData
[arg
];
14611 console
.log('argument {{' + arg
+ '}} for #' + key
+ ' is undefined.');
14612 return matched_text
;
14616 function translateElement(element
) {
14617 var l10n
= getL10nAttributes(element
);
14618 if (!l10n
.id
) return;
14619 var data
= getL10nData(l10n
.id
, l10n
.args
);
14622 console
.warn('#' + l10n
.id
+ ' is undefined.');
14626 if (data
[gTextProp
]) {
14627 if (getChildElementCount(element
) === 0) {
14628 element
[gTextProp
] = data
[gTextProp
];
14630 var children
= element
.childNodes
;
14633 for (var i
= 0, l
= children
.length
; i
< l
; i
++) {
14634 if (children
[i
].nodeType
=== 3 && /\S/.test(children
[i
].nodeValue
)) {
14636 children
[i
].nodeValue
= '';
14638 children
[i
].nodeValue
= data
[gTextProp
];
14645 var textNode
= document
.createTextNode(data
[gTextProp
]);
14646 element
.insertBefore(textNode
, element
.firstChild
);
14650 delete data
[gTextProp
];
14653 for (var k
in data
) {
14654 element
[k
] = data
[k
];
14658 function getChildElementCount(element
) {
14659 if (element
.children
) {
14660 return element
.children
.length
;
14663 if (typeof element
.childElementCount
!== 'undefined') {
14664 return element
.childElementCount
;
14669 for (var i
= 0; i
< element
.childNodes
.length
; i
++) {
14670 count
+= element
.nodeType
=== 1 ? 1 : 0;
14676 function translateFragment(element
) {
14677 element
= element
|| document
.documentElement
;
14678 var children
= getTranslatableChildren(element
);
14679 var elementCount
= children
.length
;
14681 for (var i
= 0; i
< elementCount
; i
++) {
14682 translateElement(children
[i
]);
14685 translateElement(element
);
14689 get: function (key
, args
, fallbackString
) {
14690 var index
= key
.lastIndexOf('.');
14691 var prop
= gTextProp
;
14694 prop
= key
.substring(index
+ 1);
14695 key
= key
.substring(0, index
);
14700 if (fallbackString
) {
14702 fallback
[prop
] = fallbackString
;
14705 var data
= getL10nData(key
, args
, fallback
);
14707 if (data
&& prop
in data
) {
14711 return '{{' + key
+ '}}';
14713 getData: function () {
14716 getText: function () {
14719 getLanguage: function () {
14722 setLanguage: function (lang
, callback
) {
14723 loadLocale(lang
, function () {
14724 if (callback
) callback();
14727 getDirection: function () {
14728 var rtlList
= ['ar', 'he', 'fa', 'ps', 'ur'];
14729 var shortCode
= gLanguage
.split('-', 1)[0];
14730 return rtlList
.indexOf(shortCode
) >= 0 ? 'rtl' : 'ltr';
14732 translate
: translateFragment
,
14733 getReadyState: function () {
14734 return gReadyState
;
14736 ready: function (callback
) {
14739 } else if (gReadyState
== 'complete' || gReadyState
== 'interactive') {
14740 window
.setTimeout(function () {
14743 } else if (document
.addEventListener
) {
14744 document
.addEventListener('localized', function once() {
14745 document
.removeEventListener('localized', once
);
14751 }(window
, document
);
14755 /***/ ((__unused_webpack_module
, exports
, __webpack_require__
) => {
14759 Object
.defineProperty(exports
, "__esModule", ({
14762 exports
.docPropertiesLookup
= docPropertiesLookup
;
14763 exports
.GenericScripting
= void 0;
14765 var _pdfjsLib
= __webpack_require__(5);
14767 async
function docPropertiesLookup(pdfDocument
) {
14769 baseUrl
= url
.split("#")[0];
14773 contentDispositionFilename
,
14775 } = await pdfDocument
.getMetadata();
14777 if (!contentLength
) {
14780 } = await pdfDocument
.getDownloadInfo();
14781 contentLength
= length
;
14786 filesize
: contentLength
,
14787 filename
: contentDispositionFilename
|| (0, _pdfjsLib
.getPdfFilenameFromUrl
)(url
),
14788 metadata
: metadata
?.getRaw(),
14789 authors
: metadata
?.get("dc:creator"),
14790 numPages
: pdfDocument
.numPages
,
14795 class GenericScripting
{
14796 constructor(sandboxBundleSrc
) {
14797 this._ready
= (0, _pdfjsLib
.loadScript
)(sandboxBundleSrc
, true).then(() => {
14798 return window
.pdfjsSandbox
.QuickJSSandbox();
14802 async
createSandbox(data
) {
14803 const sandbox
= await
this._ready
;
14804 sandbox
.create(data
);
14807 async
dispatchEventInSandbox(event
) {
14808 const sandbox
= await
this._ready
;
14809 sandbox
.dispatchEvent(event
);
14812 async
destroySandbox() {
14813 const sandbox
= await
this._ready
;
14814 sandbox
.nukeSandbox();
14819 exports
.GenericScripting
= GenericScripting
;
14823 /***/ ((__unused_webpack_module
, exports
, __webpack_require__
) => {
14827 Object
.defineProperty(exports
, "__esModule", ({
14830 exports
.PDFPrintService
= PDFPrintService
;
14832 var _app
= __webpack_require__(3);
14834 var _print_utils
= __webpack_require__(46);
14836 var _viewer_compatibility
= __webpack_require__(2);
14838 let activeService
= null;
14839 let overlayManager
= null;
14841 function renderPage(activeServiceOnEntry
, pdfDocument
, pageNumber
, size
, printResolution
, optionalContentConfigPromise
) {
14842 const scratchCanvas
= activeService
.scratchCanvas
;
14843 const PRINT_UNITS
= printResolution
/ 72.0;
14844 scratchCanvas
.width
= Math
.floor(size
.width
* PRINT_UNITS
);
14845 scratchCanvas
.height
= Math
.floor(size
.height
* PRINT_UNITS
);
14846 const ctx
= scratchCanvas
.getContext("2d");
14848 ctx
.fillStyle
= "rgb(255, 255, 255)";
14849 ctx
.fillRect(0, 0, scratchCanvas
.width
, scratchCanvas
.height
);
14851 return pdfDocument
.getPage(pageNumber
).then(function (pdfPage
) {
14852 const renderContext
= {
14853 canvasContext
: ctx
,
14854 transform
: [PRINT_UNITS
, 0, 0, PRINT_UNITS
, 0, 0],
14855 viewport
: pdfPage
.getViewport({
14857 rotation
: size
.rotation
14860 includeAnnotationStorage
: true,
14861 optionalContentConfigPromise
14863 return pdfPage
.render(renderContext
).promise
;
14867 function PDFPrintService(pdfDocument
, pagesOverview
, printContainer
, printResolution
, optionalContentConfigPromise
= null, l10n
) {
14868 this.pdfDocument
= pdfDocument
;
14869 this.pagesOverview
= pagesOverview
;
14870 this.printContainer
= printContainer
;
14871 this._printResolution
= printResolution
|| 150;
14872 this._optionalContentConfigPromise
= optionalContentConfigPromise
|| pdfDocument
.getOptionalContentConfig();
14874 this.currentPage
= -1;
14875 this.scratchCanvas
= document
.createElement("canvas");
14878 PDFPrintService
.prototype = {
14880 this.throwIfInactive();
14881 const body
= document
.querySelector("body");
14882 body
.setAttribute("data-pdfjsprinting", true);
14883 const hasEqualPageSizes
= this.pagesOverview
.every(function (size
) {
14884 return size
.width
=== this.pagesOverview
[0].width
&& size
.height
=== this.pagesOverview
[0].height
;
14887 if (!hasEqualPageSizes
) {
14888 console
.warn("Not all pages have the same size. The printed " + "result may be incorrect!");
14891 this.pageStyleSheet
= document
.createElement("style");
14892 const pageSize
= this.pagesOverview
[0];
14893 this.pageStyleSheet
.textContent
= "@page { size: " + pageSize
.width
+ "pt " + pageSize
.height
+ "pt;}";
14894 body
.appendChild(this.pageStyleSheet
);
14898 if (activeService
!== this) {
14902 this.printContainer
.textContent
= "";
14903 const body
= document
.querySelector("body");
14904 body
.removeAttribute("data-pdfjsprinting");
14906 if (this.pageStyleSheet
) {
14907 this.pageStyleSheet
.remove();
14908 this.pageStyleSheet
= null;
14911 this.scratchCanvas
.width
= this.scratchCanvas
.height
= 0;
14912 this.scratchCanvas
= null;
14913 activeService
= null;
14914 ensureOverlay().then(function () {
14915 if (overlayManager
.active
!== "printServiceOverlay") {
14919 overlayManager
.close("printServiceOverlay");
14924 if (this.pdfDocument
.isPureXfa
) {
14925 (0, _print_utils
.getXfaHtmlForPrinting
)(this.printContainer
, this.pdfDocument
);
14926 return Promise
.resolve();
14929 const pageCount
= this.pagesOverview
.length
;
14931 const renderNextPage
= (resolve
, reject
) => {
14932 this.throwIfInactive();
14934 if (++this.currentPage
>= pageCount
) {
14935 renderProgress(pageCount
, pageCount
, this.l10n
);
14940 const index
= this.currentPage
;
14941 renderProgress(index
, pageCount
, this.l10n
);
14942 renderPage(this, this.pdfDocument
, index
+ 1, this.pagesOverview
[index
], this._printResolution
, this._optionalContentConfigPromise
).then(this.useRenderedPage
.bind(this)).then(function () {
14943 renderNextPage(resolve
, reject
);
14947 return new Promise(renderNextPage
);
14950 useRenderedPage() {
14951 this.throwIfInactive();
14952 const img
= document
.createElement("img");
14953 const scratchCanvas
= this.scratchCanvas
;
14955 if ("toBlob" in scratchCanvas
&& !_viewer_compatibility
.viewerCompatibilityParams
.disableCreateObjectURL
) {
14956 scratchCanvas
.toBlob(function (blob
) {
14957 img
.src
= URL
.createObjectURL(blob
);
14960 img
.src
= scratchCanvas
.toDataURL();
14963 const wrapper
= document
.createElement("div");
14964 wrapper
.className
= "printedPage";
14965 wrapper
.appendChild(img
);
14966 this.printContainer
.appendChild(wrapper
);
14967 return new Promise(function (resolve
, reject
) {
14968 img
.onload
= resolve
;
14969 img
.onerror
= reject
;
14974 this.throwIfInactive();
14975 return new Promise(resolve
=> {
14977 if (!this.active
) {
14982 print
.call(window
);
14983 setTimeout(resolve
, 20);
14989 return this === activeService
;
14992 throwIfInactive() {
14993 if (!this.active
) {
14994 throw new Error("This print request was cancelled or completed.");
14999 const print
= window
.print
;
15001 window
.print = function () {
15002 if (activeService
) {
15003 console
.warn("Ignored window.print() because of a pending print job.");
15007 ensureOverlay().then(function () {
15008 if (activeService
) {
15009 overlayManager
.open("printServiceOverlay");
15014 dispatchEvent("beforeprint");
15016 if (!activeService
) {
15017 console
.error("Expected print service to be initialized.");
15018 ensureOverlay().then(function () {
15019 if (overlayManager
.active
=== "printServiceOverlay") {
15020 overlayManager
.close("printServiceOverlay");
15026 const activeServiceOnEntry
= activeService
;
15027 activeService
.renderPages().then(function () {
15028 return activeServiceOnEntry
.performPrint();
15029 }).catch(function () {}).then(function () {
15030 if (activeServiceOnEntry
.active
) {
15037 function dispatchEvent(eventType
) {
15038 const event
= document
.createEvent("CustomEvent");
15039 event
.initCustomEvent(eventType
, false, false, "custom");
15040 window
.dispatchEvent(event
);
15044 if (activeService
) {
15045 activeService
.destroy();
15046 dispatchEvent("afterprint");
15050 function renderProgress(index
, total
, l10n
) {
15051 const progressContainer
= document
.getElementById("printServiceOverlay");
15052 const progress
= Math
.round(100 * index
/ total
);
15053 const progressBar
= progressContainer
.querySelector("progress");
15054 const progressPerc
= progressContainer
.querySelector(".relative-progress");
15055 progressBar
.value
= progress
;
15056 l10n
.get("print_progress_percent", {
15059 progressPerc
.textContent
= msg
;
15063 window
.addEventListener("keydown", function (event
) {
15064 if (event
.keyCode
=== 80 && (event
.ctrlKey
|| event
.metaKey
) && !event
.altKey
&& (!event
.shiftKey
|| window
.chrome
|| window
.opera
)) {
15066 event
.preventDefault();
15068 if (event
.stopImmediatePropagation
) {
15069 event
.stopImmediatePropagation();
15071 event
.stopPropagation();
15076 if ("onbeforeprint" in window
) {
15077 const stopPropagationIfNeeded = function (event
) {
15078 if (event
.detail
!== "custom" && event
.stopImmediatePropagation
) {
15079 event
.stopImmediatePropagation();
15083 window
.addEventListener("beforeprint", stopPropagationIfNeeded
);
15084 window
.addEventListener("afterprint", stopPropagationIfNeeded
);
15087 let overlayPromise
;
15089 function ensureOverlay() {
15090 if (!overlayPromise
) {
15091 overlayManager
= _app
.PDFViewerApplication
.overlayManager
;
15093 if (!overlayManager
) {
15094 throw new Error("The overlay manager has not yet been initialized.");
15097 overlayPromise
= overlayManager
.register("printServiceOverlay", document
.getElementById("printServiceOverlay"), abort
, true);
15098 document
.getElementById("printCancel").onclick
= abort
;
15101 return overlayPromise
;
15104 _app
.PDFPrintServiceFactory
.instance
= {
15105 supportsPrinting
: true,
15107 createPrintService(pdfDocument
, pagesOverview
, printContainer
, printResolution
, optionalContentConfigPromise
, l10n
) {
15108 if (activeService
) {
15109 throw new Error("The print service is created and active.");
15112 activeService
= new PDFPrintService(pdfDocument
, pagesOverview
, printContainer
, printResolution
, optionalContentConfigPromise
, l10n
);
15113 return activeService
;
15120 /***/ ((__unused_webpack_module
, exports
, __webpack_require__
) => {
15124 Object
.defineProperty(exports
, "__esModule", ({
15127 exports
.getXfaHtmlForPrinting
= getXfaHtmlForPrinting
;
15129 var _ui_utils
= __webpack_require__(4);
15131 var _xfa_layer_builder
= __webpack_require__(34);
15133 var _pdfjsLib
= __webpack_require__(5);
15135 function getXfaHtmlForPrinting(printContainer
, pdfDocument
) {
15136 const xfaHtml
= pdfDocument
.allXfaHtml
;
15137 const factory
= new _xfa_layer_builder
.DefaultXfaLayerFactory();
15138 const scale
= Math
.round(_ui_utils
.CSS_UNITS
* 100) / 100;
15140 for (const xfaPage
of xfaHtml
.children
) {
15141 const page
= document
.createElement("div");
15142 page
.className
= "xfaPrintedPage";
15143 printContainer
.appendChild(page
);
15144 const builder
= factory
.createXfaLayerBuilder(page
, null, pdfDocument
.annotationStorage
, xfaPage
);
15145 const viewport
= (0, _pdfjsLib
.getXfaPageViewport
)(xfaPage
, {
15148 builder
.render(viewport
, "print");
15154 /************************************************************************/
15155 /******/ // The module cache
15156 /******/ var __webpack_module_cache__
= {};
15158 /******/ // The require function
15159 /******/ function __webpack_require__(moduleId
) {
15160 /******/ // Check if module is in cache
15161 /******/ var cachedModule
= __webpack_module_cache__
[moduleId
];
15162 /******/ if (cachedModule
!== undefined) {
15163 /******/ return cachedModule
.exports
;
15165 /******/ // Create a new module (and put it into the cache)
15166 /******/ var module
= __webpack_module_cache__
[moduleId
] = {
15167 /******/ // no module.id needed
15168 /******/ // no module.loaded needed
15169 /******/ exports
: {}
15172 /******/ // Execute the module function
15173 /******/ __webpack_modules__
[moduleId
](module
, module
.exports
, __webpack_require__
);
15175 /******/ // Return the exports of the module
15176 /******/ return module
.exports
;
15179 /************************************************************************/
15180 var __webpack_exports__
= {};
15181 // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
15183 var exports
= __webpack_exports__
;
15186 Object
.defineProperty(exports
, "__esModule", ({
15189 Object
.defineProperty(exports
, "PDFViewerApplicationOptions", ({
15192 return _app_options
.AppOptions
;
15195 Object
.defineProperty(exports
, "PDFViewerApplication", ({
15198 return _app
.PDFViewerApplication
;
15202 var _app_options
= __webpack_require__(1);
15204 var _app
= __webpack_require__(3);
15206 const pdfjsVersion
= '2.10.377';
15207 const pdfjsBuild
= '156762c48';
15208 window
.PDFViewerApplication
= _app
.PDFViewerApplication
;
15209 window
.PDFViewerApplicationOptions
= _app_options
.AppOptions
;
15213 __webpack_require__(39);
15217 __webpack_require__(45);
15220 function getViewerConfiguration() {
15221 let errorWrapper
= null;
15223 container
: document
.getElementById("errorWrapper"),
15224 errorMessage
: document
.getElementById("errorMessage"),
15225 closeButton
: document
.getElementById("errorClose"),
15226 errorMoreInfo
: document
.getElementById("errorMoreInfo"),
15227 moreInfoButton
: document
.getElementById("errorShowMore"),
15228 lessInfoButton
: document
.getElementById("errorShowLess")
15231 appContainer
: document
.body
,
15232 mainContainer
: document
.getElementById("viewerContainer"),
15233 viewerContainer
: document
.getElementById("viewer"),
15236 container
: document
.getElementById("toolbarViewer"),
15237 numPages
: document
.getElementById("numPages"),
15238 pageNumber
: document
.getElementById("pageNumber"),
15239 scaleSelectContainer
: document
.getElementById("scaleSelectContainer"),
15240 scaleSelect
: document
.getElementById("scaleSelect"),
15241 customScaleOption
: document
.getElementById("customScaleOption"),
15242 previous
: document
.getElementById("previous"),
15243 next
: document
.getElementById("next"),
15244 zoomIn
: document
.getElementById("zoomIn"),
15245 zoomOut
: document
.getElementById("zoomOut"),
15246 viewFind
: document
.getElementById("viewFind"),
15247 openFile
: document
.getElementById("openFile"),
15248 print
: document
.getElementById("print"),
15249 presentationModeButton
: document
.getElementById("presentationMode"),
15250 download
: document
.getElementById("download"),
15251 viewBookmark
: document
.getElementById("viewBookmark")
15253 secondaryToolbar
: {
15254 toolbar
: document
.getElementById("secondaryToolbar"),
15255 toggleButton
: document
.getElementById("secondaryToolbarToggle"),
15256 toolbarButtonContainer
: document
.getElementById("secondaryToolbarButtonContainer"),
15257 presentationModeButton
: document
.getElementById("secondaryPresentationMode"),
15258 openFileButton
: document
.getElementById("secondaryOpenFile"),
15259 printButton
: document
.getElementById("secondaryPrint"),
15260 downloadButton
: document
.getElementById("secondaryDownload"),
15261 viewBookmarkButton
: document
.getElementById("secondaryViewBookmark"),
15262 firstPageButton
: document
.getElementById("firstPage"),
15263 lastPageButton
: document
.getElementById("lastPage"),
15264 pageRotateCwButton
: document
.getElementById("pageRotateCw"),
15265 pageRotateCcwButton
: document
.getElementById("pageRotateCcw"),
15266 cursorSelectToolButton
: document
.getElementById("cursorSelectTool"),
15267 cursorHandToolButton
: document
.getElementById("cursorHandTool"),
15268 scrollVerticalButton
: document
.getElementById("scrollVertical"),
15269 scrollHorizontalButton
: document
.getElementById("scrollHorizontal"),
15270 scrollWrappedButton
: document
.getElementById("scrollWrapped"),
15271 spreadNoneButton
: document
.getElementById("spreadNone"),
15272 spreadOddButton
: document
.getElementById("spreadOdd"),
15273 spreadEvenButton
: document
.getElementById("spreadEven"),
15274 documentPropertiesButton
: document
.getElementById("documentProperties")
15277 outerContainer
: document
.getElementById("outerContainer"),
15278 viewerContainer
: document
.getElementById("viewerContainer"),
15279 toggleButton
: document
.getElementById("sidebarToggle"),
15280 thumbnailButton
: document
.getElementById("viewThumbnail"),
15281 outlineButton
: document
.getElementById("viewOutline"),
15282 attachmentsButton
: document
.getElementById("viewAttachments"),
15283 layersButton
: document
.getElementById("viewLayers"),
15284 thumbnailView
: document
.getElementById("thumbnailView"),
15285 outlineView
: document
.getElementById("outlineView"),
15286 attachmentsView
: document
.getElementById("attachmentsView"),
15287 layersView
: document
.getElementById("layersView"),
15288 outlineOptionsContainer
: document
.getElementById("outlineOptionsContainer"),
15289 currentOutlineItemButton
: document
.getElementById("currentOutlineItem")
15292 outerContainer
: document
.getElementById("outerContainer"),
15293 resizer
: document
.getElementById("sidebarResizer")
15296 bar
: document
.getElementById("findbar"),
15297 toggleButton
: document
.getElementById("viewFind"),
15298 findField
: document
.getElementById("findInput"),
15299 highlightAllCheckbox
: document
.getElementById("findHighlightAll"),
15300 caseSensitiveCheckbox
: document
.getElementById("findMatchCase"),
15301 entireWordCheckbox
: document
.getElementById("findEntireWord"),
15302 findMsg
: document
.getElementById("findMsg"),
15303 findResultsCount
: document
.getElementById("findResultsCount"),
15304 findPreviousButton
: document
.getElementById("findPrevious"),
15305 findNextButton
: document
.getElementById("findNext")
15308 overlayName
: "passwordOverlay",
15309 container
: document
.getElementById("passwordOverlay"),
15310 label
: document
.getElementById("passwordText"),
15311 input
: document
.getElementById("password"),
15312 submitButton
: document
.getElementById("passwordSubmit"),
15313 cancelButton
: document
.getElementById("passwordCancel")
15315 documentProperties
: {
15316 overlayName
: "documentPropertiesOverlay",
15317 container
: document
.getElementById("documentPropertiesOverlay"),
15318 closeButton
: document
.getElementById("documentPropertiesClose"),
15320 fileName
: document
.getElementById("fileNameField"),
15321 fileSize
: document
.getElementById("fileSizeField"),
15322 title
: document
.getElementById("titleField"),
15323 author
: document
.getElementById("authorField"),
15324 subject
: document
.getElementById("subjectField"),
15325 keywords
: document
.getElementById("keywordsField"),
15326 creationDate
: document
.getElementById("creationDateField"),
15327 modificationDate
: document
.getElementById("modificationDateField"),
15328 creator
: document
.getElementById("creatorField"),
15329 producer
: document
.getElementById("producerField"),
15330 version
: document
.getElementById("versionField"),
15331 pageCount
: document
.getElementById("pageCountField"),
15332 pageSize
: document
.getElementById("pageSizeField"),
15333 linearized
: document
.getElementById("linearizedField")
15337 printContainer
: document
.getElementById("printContainer"),
15338 openFileInputName
: "fileInput",
15339 debuggerScriptPath
: "./debugger.js"
15343 function webViewerLoad() {
15344 const config
= getViewerConfiguration();
15345 const event
= document
.createEvent("CustomEvent");
15346 event
.initCustomEvent("webviewerloaded", true, true, {
15351 parent
.document
.dispatchEvent(event
);
15353 console
.error(`webviewerloaded: ${ex}`);
15354 document
.dispatchEvent(event
);
15357 _app
.PDFViewerApplication
.run(config
);
15360 if (document
.blockUnblockOnload
) {
15361 document
.blockUnblockOnload(true);
15364 if (document
.readyState
=== "interactive" || document
.readyState
=== "complete") {
15367 document
.addEventListener("DOMContentLoaded", webViewerLoad
, true);
15373 //# sourceMappingURL=viewer.js.map