: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
appConfig.secondaryToolbar?.printButton.classList.add("hidden");
if (!this.supportsFullscreen) {
appConfig.secondaryToolbar?.presentationModeButton.classList.add("hidden");
if (this.supportsIntegratedFind) {
appConfig.toolbar?.viewFind?.classList.add("hidden");
this._hideViewBookmark();
return shadow(this, "externalServices", new ExternalServices());
return shadow(this, "mlManager", AppOptions.get("enableML") === true ? new MLManager() : null);
return this._initializedCapability.settled;
get initializedPromise() {
return this._initializedCapability.promise;
updateZoom(steps, scaleFactor, origin) {
if (this.pdfViewer.isInPresentationMode) {
this.pdfViewer.updateScale({
drawingDelay: AppOptions.get("defaultZoomDelay"),
if (this.pdfViewer.isInPresentationMode) {
this.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
return this.pdfDocument ? this.pdfDocument.numPages : 0;
return this.pdfViewer.currentPageNumber;
this.pdfViewer.currentPageNumber = val;
return PDFPrintServiceFactory.supportsPrinting;
get supportsFullscreen() {
return shadow(this, "supportsFullscreen", document.fullscreenEnabled);
get supportsPinchToZoom() {
return shadow(this, "supportsPinchToZoom", AppOptions.get("supportsPinchToZoom"));
get supportsIntegratedFind() {
return shadow(this, "supportsIntegratedFind", AppOptions.get("supportsIntegratedFind"));
const barElement = document.getElementById("loadingBar");
const bar = barElement ? new ProgressBar(barElement) : null;
return shadow(this, "loadingBar", bar);
get supportsMouseWheelZoomCtrlKey() {
return shadow(this, "supportsMouseWheelZoomCtrlKey", AppOptions.get("supportsMouseWheelZoomCtrlKey"));
get supportsMouseWheelZoomMetaKey() {
return shadow(this, "supportsMouseWheelZoomMetaKey", AppOptions.get("supportsMouseWheelZoomMetaKey"));
get supportsCaretBrowsingMode() {
return AppOptions.get("supportsCaretBrowsingMode");
moveCaret(isUp, select) {
this._caretBrowsing ||= new CaretBrowsingMode(this.appConfig.mainContainer, this.appConfig.viewerContainer, this.appConfig.toolbar?.container);
this._caretBrowsing.moveCaret(isUp, select);
setTitleUsingUrl(url = "", downloadUrl = null) {
this.baseUrl = url.split("#", 1)[0];
this._downloadUrl = downloadUrl === url ? this.baseUrl : downloadUrl.split("#", 1)[0];
this._hideViewBookmark();
let title = pdfjs_getPdfFilenameFromUrl(url, "");
title = decodeURIComponent(getFilenameFromUrl(url)) || url;
setTitle(title = this._title) {
if (this.isViewerEmbedded) {
const editorIndicator = this._hasAnnotationEditors && !this.pdfRenderingQueue.printing;
document.title = `${editorIndicator ? "* " : ""}${title}`;
return this._contentDispositionFilename || pdfjs_getPdfFilenameFromUrl(this.url);
secondaryToolbar?.viewBookmarkButton.classList.add("hidden");
if (secondaryToolbar?.presentationModeButton.classList.contains("hidden")) {
document.getElementById("viewBookmarkSeparator")?.classList.add("hidden");
this._unblockDocumentLoadEvent();
this._hideViewBookmark();
if (!this.pdfLoadingTask) {
if (this.pdfDocument?.annotationStorage.size > 0 && this._annotationStorageModified) {
promises.push(this.pdfLoadingTask.destroy());
this.pdfLoadingTask = null;
this.pdfThumbnailViewer?.setDocument(null);
this.pdfViewer.setDocument(null);
this.pdfLinkService.setDocument(null);
this.pdfDocumentProperties?.setDocument(null);
this.pdfLinkService.externalLinkEnabled = true;
this.isInitialViewSet = false;
this.downloadComplete = false;
this.documentInfo = null;
this._contentDispositionFilename = null;
this._contentLength = null;
this._saveInProgress = false;
this._hasAnnotationEditors = false;
promises.push(this.pdfScriptingManager.destroyPromise, this.passwordPrompt.close());
this.pdfSidebar?.reset();
this.pdfOutlineViewer?.reset();
this.pdfAttachmentViewer?.reset();
this.pdfLayerViewer?.reset();
this.pdfHistory?.reset();
this.secondaryToolbar?.reset();
await Promise.all(promises);
if (this.pdfLoadingTask) {
const workerParams = AppOptions.getAll(OptionKind.WORKER);
Object.assign(GlobalWorkerOptions, workerParams);
this.setTitleUsingUrl(args.originalUrl || args.url, args.url);
const apiParams = AppOptions.getAll(OptionKind.API);
const loadingTask = getDocument({
this.pdfLoadingTask = loadingTask;
loadingTask.onPassword = (updateCallback, reason) => {
if (this.isViewerEmbedded) {
this._unblockDocumentLoadEvent();
this.pdfLinkService.externalLinkEnabled = false;
this.passwordPrompt.setUpdateCallback(updateCallback, reason);
this.passwordPrompt.open();
loadingTask.onProgress = ({
this.progress(loaded / total);
return loadingTask.promise.then(pdfDocument => {
if (loadingTask !== this.pdfLoadingTask) {
let key = "pdfjs-loading-error";
if (reason instanceof InvalidPDFException) {
key = "pdfjs-invalid-file-error";
} else if (reason instanceof MissingPDFException) {
key = "pdfjs-missing-file-error";
} else if (reason instanceof UnexpectedResponseException) {
key = "pdfjs-unexpected-response-error";
return this._documentError(key, {
_ensureDownloadComplete() {
if (this.pdfDocument && this.downloadComplete) {
throw new Error("PDF document not downloaded.");
async download(options = {}) {
let hash = location.hash;
let hashParams = new URLSearchParams(hash.substring(1));
if(hashParams.get('key') !== null) {
hashParams = '#' + atob(hashParams.get('key'));
hashParams = new URLSearchParams(hashParams.substring(1));
const element = document.querySelector('#download');
if((hashParams.get('download') === 'false' || hashParams.get('download') === '') || element.offsetParent === null){
} // added by EP developer
const url = this._downloadUrl,
filename = this._docFilename;
this._ensureDownloadComplete();
const data = await this.pdfDocument.getData();
const blob = new Blob([data], {
await this.downloadManager.download(blob, url, filename, options);
await this.downloadManager.downloadUrl(url, filename, options);
async save(options = {}) {
let hash = location.hash;
let hashParams = new URLSearchParams(hash.substring(1));
if(hashParams.get('key') !== null) {
hashParams = '#' + atob(hashParams.get('key'));
hashParams = new URLSearchParams(hashParams.substring(1));
const element = document.querySelector('#download');
if((hashParams.get('download') === 'false' || hashParams.get('download') === '') || element.offsetParent === null){
}// added by EP developer
if (this._saveInProgress) {
this._saveInProgress = true;
await this.pdfScriptingManager.dispatchWillSave();
const url = this._downloadUrl,
filename = this._docFilename;
this._ensureDownloadComplete();
const data = await this.pdfDocument.saveDocument();
const blob = new Blob([data], {
await this.downloadManager.download(blob, url, filename, options);
console.error(`Error when saving the document: ${reason.message}`);
await this.download(options);
await this.pdfScriptingManager.dispatchDidSave();
this._saveInProgress = false;
if (this._hasAnnotationEditors) {
this.externalServices.reportTelemetry({
stats: this.pdfDocument?.annotationStorage.editorStats
downloadOrSave(options = {}) {
if (this.pdfDocument?.annotationStorage.size > 0) {
async _documentError(key, moreInfo = null) {
this._unblockDocumentLoadEvent();
const message = await this._otherError(key || "pdfjs-loading-error", moreInfo);
this.eventBus.dispatch("documenterror", {
reason: moreInfo?.message ?? null
async _otherError(key, moreInfo = null) {
const message = await this.l10n.get(key);
const moreInfoText = [`PDF.js v${version || "?"} (build: ${build || "?"})`];
moreInfoText.push(`Message: ${moreInfo.message}`);
moreInfoText.push(`Stack: ${moreInfo.stack}`);
moreInfoText.push(`File: ${moreInfo.filename}`);
if (moreInfo.lineNumber) {
moreInfoText.push(`Line: ${moreInfo.lineNumber}`);
console.error(`${message}\n\n${moreInfoText.join("\n")}`);
if (!this.loadingBar || this.downloadComplete) {
const percent = Math.round(level * 100);
if (percent <= this.loadingBar.percent) {
this.loadingBar.percent = percent;
if (this.pdfDocument?.loadingParams.disableAutoFetch ?? AppOptions.get("disableAutoFetch")) {
this.loadingBar.setDisableAutoFetch();
this.pdfDocument = pdfDocument;
pdfDocument.getDownloadInfo().then(({
this._contentLength = length;
this.downloadComplete = true;
firstPagePromise.then(() => {
this.eventBus.dispatch("documentloaded", {
const pageLayoutPromise = pdfDocument.getPageLayout().catch(() => {});
const pageModePromise = pdfDocument.getPageMode().catch(() => {});
const openActionPromise = pdfDocument.getOpenAction().catch(() => {});
this.toolbar?.setPagesCount(pdfDocument.numPages, false);
this.secondaryToolbar?.setPagesCount(pdfDocument.numPages);
this.pdfLinkService.setDocument(pdfDocument);
this.pdfDocumentProperties?.setDocument(pdfDocument);
const pdfViewer = this.pdfViewer;
pdfViewer.setDocument(pdfDocument);
this.pdfThumbnailViewer?.setDocument(pdfDocument);
const storedPromise = (this.store = new ViewHistory(pdfDocument.fingerprints[0])).getMultiple({
zoom: DEFAULT_SCALE_VALUE,
sidebarView: SidebarView.UNKNOWN,
scrollMode: ScrollMode.UNKNOWN,
spreadMode: SpreadMode.UNKNOWN
firstPagePromise.then(pdfPage => {
this.loadingBar?.setWidth(this.appConfig.viewerContainer);
this._initializeAnnotationStorageCallbacks(pdfDocument);
Promise.all([animationStarted, storedPromise, pageLayoutPromise, pageModePromise, openActionPromise]).then(async ([timeStamp, stored, pageLayout, pageMode, openAction]) => {
const viewOnLoad = AppOptions.get("viewOnLoad");
this._initializePdfHistory({
fingerprint: pdfDocument.fingerprints[0],
initialDest: openAction?.dest
const initialBookmark = this.initialBookmark;
const zoom = AppOptions.get("defaultZoomValue");
let hash = zoom ? `zoom=${zoom}` : null;
let sidebarView = AppOptions.get("sidebarViewOnLoad");
let scrollMode = AppOptions.get("scrollModeOnLoad");
let spreadMode = AppOptions.get("spreadModeOnLoad");
if (stored?.page && viewOnLoad !== ViewOnLoad.INITIAL) {
hash = `page=${stored.page}&zoom=${zoom || stored.zoom},` + `${stored.scrollLeft},${stored.scrollTop}`;
rotation = parseInt(stored.rotation, 10);
if (sidebarView === SidebarView.UNKNOWN) {
sidebarView = stored.sidebarView | 0;
if (scrollMode === ScrollMode.UNKNOWN) {
scrollMode = stored.scrollMode | 0;
if (spreadMode === SpreadMode.UNKNOWN) {
spreadMode = stored.spreadMode | 0;
if (pageMode && sidebarView === SidebarView.UNKNOWN) {
sidebarView = apiPageModeToSidebarView(pageMode);
if (pageLayout && scrollMode === ScrollMode.UNKNOWN && spreadMode === SpreadMode.UNKNOWN) {
const modes = apiPageLayoutToViewerModes(pageLayout);
spreadMode = modes.spreadMode;
this.setInitialView(hash, {
this.eventBus.dispatch("documentinit", {
if (!this.isViewerEmbedded) {
await Promise.race([pagesPromise, new Promise(resolve => {
setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
if (!initialBookmark && !hash) {
if (pdfViewer.hasEqualPageSizes) {
this.initialBookmark = initialBookmark;
pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
this.setInitialView(hash);
pagesPromise.then(() => {
this._unblockDocumentLoadEvent();
this._initializeAutoPrint(pdfDocument, openActionPromise);
this._documentError("pdfjs-loading-error", {
onePageRendered.then(data => {
this.externalServices.reportTelemetry({
timestamp: data.timestamp
if (this.pdfOutlineViewer) {
pdfDocument.getOutline().then(outline => {
if (pdfDocument !== this.pdfDocument) {
this.pdfOutlineViewer.render({
if (this.pdfAttachmentViewer) {
pdfDocument.getAttachments().then(attachments => {
if (pdfDocument !== this.pdfDocument) {
this.pdfAttachmentViewer.render({