: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
while (database.files.length >= this.cacheSize) {
for (let i = 0, ii = database.files.length; i < ii; i++) {
const branch = database.files[i];
if (branch.fingerprint === this.fingerprint) {
index = database.files.push({
fingerprint: this.fingerprint
this.file = database.files[index];
this.database = database;
async _writeToStorage() {
const databaseStr = JSON.stringify(this.database);
localStorage.setItem("pdfjs.history", databaseStr);
async _readFromStorage() {
return localStorage.getItem("pdfjs.history");
await this._initializedPromise;
return this._writeToStorage();
async setMultiple(properties) {
await this._initializedPromise;
for (const name in properties) {
this.file[name] = properties[name];
return this._writeToStorage();
async get(name, defaultValue) {
await this._initializedPromise;
const val = this.file[name];
return val !== undefined ? val : defaultValue;
async getMultiple(properties) {
await this._initializedPromise;
const values = Object.create(null);
for (const name in properties) {
const val = this.file[name];
values[name] = val !== undefined ? val : properties[name];
;// CONCATENATED MODULE: ./web/app.js
const FORCE_PAGES_LOADED_TIMEOUT = 10000;
const WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
const PDFViewerApplication = {
initialBookmark: document.location.hash.substring(1),
_initializedCapability: {
...Promise.withResolvers(),
pdfThumbnailViewer: null,
pdfPresentationMode: null,
pdfDocumentProperties: null,
pdfAttachmentViewer: null,
pdfScriptingManager: null,
annotationEditorParams: null,
isViewerEmbedded: window.parent !== window,
_eventBusAbortController: null,
_windowAbortController: null,
_contentDispositionFilename: null,
_hasAnnotationEditors: false,
_printAnnotationStoragePromise: null,
_nimbusDataPromise: null,
async initialize(appConfig) {
this.appConfig = appConfig;
await this.preferences.initializedPromise;
console.error(`initialize: "${ex.message}".`);
if (AppOptions.get("pdfBugEnabled")) {
await this._parseHashParams();
switch (AppOptions.get("viewerCssTheme")) {
document.documentElement.classList.add(mode);
l10nPromise = this.externalServices.createL10n();
this.l10n = await l10nPromise;
document.getElementsByTagName("html")[0].dir = this.l10n.getDirection();
this.l10n.translate(appConfig.appContainer || document.documentElement);
if (this.isViewerEmbedded && AppOptions.get("externalLinkTarget") === LinkTarget.NONE) {
AppOptions.set("externalLinkTarget", LinkTarget.TOP);
await this._initializeViewerComponents();
this._initializedCapability.settled = true;
this._initializedCapability.resolve();
async _parseHashParams() {
const hash = document.location.hash.substring(1);
params = parseQueryString(hash);
const loadPDFBug = async () => {
} = await import( /*webpackIgnore: true*/AppOptions.get("debuggerSrc"));
if (params.get("disableworker") === "true") {
GlobalWorkerOptions.workerSrc ||= AppOptions.get("workerSrc");
await import( /*webpackIgnore: true*/PDFWorker.workerSrc);
console.error(`_parseHashParams: "${ex.message}".`);
if (params.has("disablerange")) {
AppOptions.set("disableRange", params.get("disablerange") === "true");
if (params.has("disablestream")) {
AppOptions.set("disableStream", params.get("disablestream") === "true");
if (params.has("disableautofetch")) {
AppOptions.set("disableAutoFetch", params.get("disableautofetch") === "true");
if (params.has("disablefontface")) {
AppOptions.set("disableFontFace", params.get("disablefontface") === "true");
if (params.has("disablehistory")) {
AppOptions.set("disableHistory", params.get("disablehistory") === "true");
if (params.has("verbosity")) {
AppOptions.set("verbosity", params.get("verbosity") | 0);
if (params.has("textlayer")) {
switch (params.get("textlayer")) {
AppOptions.set("textLayerMode", TextLayerMode.DISABLE);
viewerContainer.classList.add(`textLayer-${params.get("textlayer")}`);
console.error(`_parseHashParams: "${ex.message}".`);
if (params.has("pdfbug")) {
fontExtraProperties: true
const enabled = params.get("pdfbug").split(",");
this._PDFBug.init(mainContainer, enabled);
console.error(`_parseHashParams: "${ex.message}".`);
if (params.has("locale")) {
AppOptions.set("locale", params.get("locale"));
async _initializeViewerComponents() {
const eventBus = AppOptions.get("isInAutomation") ? new AutomationEventBus() : new EventBus();
this.eventBus = eventBus;
this.overlayManager = new OverlayManager();
const pdfRenderingQueue = new PDFRenderingQueue();
pdfRenderingQueue.onIdle = this._cleanup.bind(this);
this.pdfRenderingQueue = pdfRenderingQueue;
const pdfLinkService = new PDFLinkService({
externalLinkTarget: AppOptions.get("externalLinkTarget"),
externalLinkRel: AppOptions.get("externalLinkRel"),
ignoreDestinationZoom: AppOptions.get("ignoreDestinationZoom")
this.pdfLinkService = pdfLinkService;
const downloadManager = this.downloadManager = new DownloadManager();
const findController = new PDFFindController({
linkService: pdfLinkService,
updateMatchesCountOnProgress: true
this.findController = findController;
const pdfScriptingManager = new PDFScriptingManager({
docProperties: this._scriptingDocProperties.bind(this)
this.pdfScriptingManager = pdfScriptingManager;
const container = appConfig.mainContainer,
viewer = appConfig.viewerContainer;
const annotationEditorMode = AppOptions.get("annotationEditorMode");
const pageColors = AppOptions.get("forcePageColors") || window.matchMedia("(forced-colors: active)").matches ? {
background: AppOptions.get("pageColorsBackground"),
foreground: AppOptions.get("pageColorsForeground")
const altTextManager = appConfig.altTextDialog ? new AltTextManager(appConfig.altTextDialog, container, this.overlayManager, eventBus) : null;
const pdfViewer = new PDFViewer({
renderingQueue: pdfRenderingQueue,
linkService: pdfLinkService,
scriptingManager: AppOptions.get("enableScripting") && pdfScriptingManager,
textLayerMode: AppOptions.get("textLayerMode"),
annotationMode: AppOptions.get("annotationMode"),
annotationEditorHighlightColors: AppOptions.get("highlightEditorColors"),
enableHighlightFloatingButton: AppOptions.get("enableHighlightFloatingButton"),
imageResourcesPath: AppOptions.get("imageResourcesPath"),
enablePrintAutoRotate: AppOptions.get("enablePrintAutoRotate"),
maxCanvasPixels: AppOptions.get("maxCanvasPixels"),
enablePermissions: AppOptions.get("enablePermissions"),
mlManager: this.mlManager
this.pdfViewer = pdfViewer;
pdfRenderingQueue.setViewer(pdfViewer);
pdfLinkService.setViewer(pdfViewer);
pdfScriptingManager.setViewer(pdfViewer);
if (appConfig.sidebar?.thumbnailView) {
this.pdfThumbnailViewer = new PDFThumbnailViewer({
container: appConfig.sidebar.thumbnailView,
renderingQueue: pdfRenderingQueue,
linkService: pdfLinkService,
pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
if (!this.isViewerEmbedded && !AppOptions.get("disableHistory")) {
this.pdfHistory = new PDFHistory({
linkService: pdfLinkService,
pdfLinkService.setHistory(this.pdfHistory);
if (!this.supportsIntegratedFind && appConfig.findBar) {
this.findBar = new PDFFindBar(appConfig.findBar, eventBus);
if (appConfig.annotationEditorParams) {
if (annotationEditorMode !== AnnotationEditorType.DISABLE) {
if (AppOptions.get("enableStampEditor")) {
appConfig.toolbar?.editorStampButton?.classList.remove("hidden");
const editorHighlightButton = appConfig.toolbar?.editorHighlightButton;
if (editorHighlightButton && AppOptions.get("enableHighlightEditor")) {
editorHighlightButton.hidden = false;
this.annotationEditorParams = new AnnotationEditorParams(appConfig.annotationEditorParams, eventBus);
for (const id of ["editorModeButtons", "editorModeSeparator"]) {
document.getElementById(id)?.classList.add("hidden");
if (appConfig.documentProperties) {
this.pdfDocumentProperties = new PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, l10n, () => this._docFilename);
if (appConfig.secondaryToolbar?.cursorHandToolButton) {
this.pdfCursorTools = new PDFCursorTools({
cursorToolOnLoad: AppOptions.get("cursorToolOnLoad")
this.toolbar = new Toolbar(appConfig.toolbar, eventBus);
if (appConfig.secondaryToolbar) {
this.secondaryToolbar = new SecondaryToolbar(appConfig.secondaryToolbar, eventBus);
if (this.supportsFullscreen && appConfig.secondaryToolbar?.presentationModeButton) {
this.pdfPresentationMode = new PDFPresentationMode({
if (appConfig.passwordOverlay) {
this.passwordPrompt = new PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, this.isViewerEmbedded);
if (appConfig.sidebar?.outlineView) {
this.pdfOutlineViewer = new PDFOutlineViewer({
container: appConfig.sidebar.outlineView,
linkService: pdfLinkService,
if (appConfig.sidebar?.attachmentsView) {
this.pdfAttachmentViewer = new PDFAttachmentViewer({
container: appConfig.sidebar.attachmentsView,
if (appConfig.sidebar?.layersView) {
this.pdfLayerViewer = new PDFLayerViewer({
container: appConfig.sidebar.layersView,
this.pdfSidebar = new PDFSidebar({
elements: appConfig.sidebar,
this.pdfSidebar.onToggled = this.forceRendering.bind(this);
this.pdfSidebar.onUpdateThumbnails = () => {
for (const pageView of pdfViewer.getCachedPageViews()) {
if (pageView.renderingState === RenderingStates.FINISHED) {
this.pdfThumbnailViewer.getThumbnail(pageView.id - 1)?.setImage(pageView);
this.pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
this.preferences = new Preferences();
await this.initialize(config);
const queryString = document.location.search.substring(1);
const params = parseQueryString(queryString);
file = params.get("file") ?? AppOptions.get("defaultUrl");
const fileInput = this._openFileInput = document.createElement("input");
fileInput.id = "fileInput";
document.body.append(fileInput);
fileInput.addEventListener("change", function (evt) {
if (!files || files.length === 0) {
eventBus.dispatch("fileinputchange", {
appConfig.mainContainer.addEventListener("dragover", function (evt) {
evt.dataTransfer.dropEffect = evt.dataTransfer.effectAllowed === "copy" ? "copy" : "move";
appConfig.mainContainer.addEventListener("drop", function (evt) {
if (!files || files.length === 0) {
eventBus.dispatch("fileinputchange", {
fileInput: evt.dataTransfer
if (!AppOptions.get("supportsDocumentFonts")) {
AppOptions.set("disableFontFace", true);
this.l10n.get("pdfjs-web-fonts-disabled").then(msg => {
if (!this.supportsPrinting) {
appConfig.toolbar?.print?.classList.add("hidden");