: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
for (const pageView of this._pages) {
if (pageView.renderingState !== RenderingStates.FINISHED) {
for (const pageView of this._pages) {
pageView.cancelRendering();
async #ensurePdfPageLoaded(pageView) {
const pdfPage = await this.pdfDocument.getPage(pageView.id);
pageView.setPdfPage(pdfPage);
console.error("Unable to get page for page view", reason);
#getScrollAhead(visible) {
if (visible.first?.id === 1) {
} else if (visible.last?.id === this.pagesCount) {
switch (this._scrollMode) {
return this.#scrollModePageState.scrollDown;
case ScrollMode.HORIZONTAL:
return this.scroll.right;
forceRendering(currentlyVisiblePages) {
const visiblePages = currentlyVisiblePages || this._getVisiblePages();
const scrollAhead = this.#getScrollAhead(visiblePages);
const preRenderExtra = this._spreadMode !== SpreadMode.NONE && this._scrollMode !== ScrollMode.HORIZONTAL;
const pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead, preRenderExtra);
this.#ensurePdfPageLoaded(pageView).then(() => {
this.renderingQueue.renderView(pageView);
get hasEqualPageSizes() {
const firstPageView = this._pages[0];
for (let i = 1, ii = this._pages.length; i < ii; ++i) {
const pageView = this._pages[i];
if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
return this._pages.map(pageView => {
const viewport = pageView.pdfPage.getViewport({
const orientation = isPortraitOrientation(viewport);
if (initialOrientation === undefined) {
initialOrientation = orientation;
} else if (this.enablePrintAutoRotate && orientation !== initialOrientation) {
rotation: (viewport.rotation - 90) % 360
rotation: viewport.rotation
get optionalContentConfigPromise() {
return Promise.resolve(null);
if (!this._optionalContentConfigPromise) {
console.error("optionalContentConfigPromise: Not initialized yet.");
return this.pdfDocument.getOptionalContentConfig({
return this._optionalContentConfigPromise;
set optionalContentConfigPromise(promise) {
if (!(promise instanceof Promise)) {
throw new Error(`Invalid optionalContentConfigPromise: ${promise}`);
if (!this._optionalContentConfigPromise) {
this._optionalContentConfigPromise = promise;
optionalContentConfigPromise: promise
this.eventBus.dispatch("optionalcontentconfigchanged", {
if (this._scrollMode === mode) {
if (!isValidScrollMode(mode)) {
throw new Error(`Invalid scroll mode: ${mode}`);
if (this.pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
this._previousScrollMode = this._scrollMode;
this.eventBus.dispatch("scrollmodechanged", {
this._updateScrollMode(this._currentPageNumber);
_updateScrollMode(pageNumber = null) {
const scrollMode = this._scrollMode,
viewer.classList.toggle("scrollHorizontal", scrollMode === ScrollMode.HORIZONTAL);
viewer.classList.toggle("scrollWrapped", scrollMode === ScrollMode.WRAPPED);
if (!this.pdfDocument || !pageNumber) {
if (scrollMode === ScrollMode.PAGE) {
this.#ensurePageViewVisible();
} else if (this._previousScrollMode === ScrollMode.PAGE) {
this._updateSpreadMode();
if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
this.#setScale(this._currentScaleValue, {
this._setCurrentPageNumber(pageNumber, true);
if (this._spreadMode === mode) {
if (!isValidSpreadMode(mode)) {
throw new Error(`Invalid spread mode: ${mode}`);
this.eventBus.dispatch("spreadmodechanged", {
this._updateSpreadMode(this._currentPageNumber);
_updateSpreadMode(pageNumber = null) {
const viewer = this.viewer,
if (this._scrollMode === ScrollMode.PAGE) {
this.#ensurePageViewVisible();
if (this._spreadMode === SpreadMode.NONE) {
for (const pageView of this._pages) {
viewer.append(pageView.div);
const parity = this._spreadMode - 1;
for (let i = 0, ii = pages.length; i < ii; ++i) {
spread = document.createElement("div");
spread.className = "spread";
} else if (i % 2 === parity) {
spread = spread.cloneNode(false);
spread.append(pages[i].div);
if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
this.#setScale(this._currentScaleValue, {
this._setCurrentPageNumber(pageNumber, true);
_getPageAdvance(currentPageNumber, previous = false) {
switch (this._scrollMode) {
} = this._getVisiblePages(),
if (percent === 0 || widthPercent < 100) {
let yArray = pageLayout.get(y);
pageLayout.set(y, yArray ||= []);
for (const yArray of pageLayout.values()) {
const currentIndex = yArray.indexOf(currentPageNumber);
if (currentIndex === -1) {
const numPages = yArray.length;
for (let i = currentIndex - 1, ii = 0; i >= ii; i--) {
const currentId = yArray[i],
expectedId = yArray[i + 1] - 1;
if (currentId < expectedId) {
return currentPageNumber - expectedId;
for (let i = currentIndex + 1, ii = numPages; i < ii; i++) {
const currentId = yArray[i],
expectedId = yArray[i - 1] + 1;
if (currentId > expectedId) {
return expectedId - currentPageNumber;
const firstId = yArray[0];
if (firstId < currentPageNumber) {
return currentPageNumber - firstId + 1;
const lastId = yArray[numPages - 1];
if (lastId > currentPageNumber) {
return lastId - currentPageNumber + 1;
case ScrollMode.HORIZONTAL:
case ScrollMode.VERTICAL:
if (this._spreadMode === SpreadMode.NONE) {
const parity = this._spreadMode - 1;
if (previous && currentPageNumber % 2 !== parity) {
} else if (!previous && currentPageNumber % 2 === parity) {
} = this._getVisiblePages(),
expectedId = previous ? currentPageNumber - 1 : currentPageNumber + 1;
if (percent > 0 && widthPercent === 100) {
const currentPageNumber = this._currentPageNumber,
pagesCount = this.pagesCount;
if (currentPageNumber >= pagesCount) {
const advance = this._getPageAdvance(currentPageNumber, false) || 1;
this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount);
const currentPageNumber = this._currentPageNumber;
if (currentPageNumber <= 1) {
const advance = this._getPageAdvance(currentPageNumber, true) || 1;
this.currentPageNumber = Math.max(currentPageNumber - advance, 1);
if (steps === null && scaleFactor === null) {
throw new Error("Invalid updateScale options: either `steps` or `scaleFactor` must be provided.");
let newScale = this._currentScale;
if (scaleFactor > 0 && scaleFactor !== 1) {
newScale = Math.round(newScale * scaleFactor * 100) / 100;
const delta = steps > 0 ? DEFAULT_SCALE_DELTA : 1 / DEFAULT_SCALE_DELTA;
const round = steps > 0 ? Math.ceil : Math.floor;
newScale = round((newScale * delta).toFixed(2) * 10) / 10;
newScale = Math.max(MIN_SCALE, Math.min(MAX_SCALE, newScale));
this.#setScale(newScale, {
increaseScale(options = {}) {
steps: options.steps ?? 1
decreaseScale(options = {}) {
steps: -(options.steps ?? 1)
#updateContainerHeightCss(height = this.container.clientHeight) {
if (height !== this.#previousContainerHeight) {
this.#previousContainerHeight = height;
docStyle.setProperty("--viewer-container-height", `${height}px`);
#resizeObserverCallback(entries) {
for (const entry of entries) {
if (entry.target === this.container) {
this.#updateContainerHeightCss(Math.floor(entry.borderBoxSize[0].blockSize));
this.#containerTopLeft = null;
return this.#containerTopLeft ||= [this.container.offsetTop, this.container.offsetLeft];
get annotationEditorMode() {
return this.#annotationEditorUIManager ? this.#annotationEditorMode : AnnotationEditorType.DISABLE;
set annotationEditorMode({
if (!this.#annotationEditorUIManager) {
throw new Error(`The AnnotationEditor is not enabled.`);
if (this.#annotationEditorMode === mode) {
if (!isValidAnnotationEditorMode(mode)) {
throw new Error(`Invalid AnnotationEditor mode: ${mode}`);
this.#annotationEditorMode = mode;
this.eventBus.dispatch("annotationeditormodechanged", {
this.#annotationEditorUIManager.updateMode(mode, editId, isFromKeyboard);
set annotationEditorParams({
if (!this.#annotationEditorUIManager) {
throw new Error(`The AnnotationEditor is not enabled.`);
this.#annotationEditorUIManager.updateParams(type, value);
refresh(noUpdate = false, updateArgs = Object.create(null)) {
for (const pageView of this._pages) {
pageView.update(updateArgs);
if (this.#scaleTimeoutId !== null) {
clearTimeout(this.#scaleTimeoutId);
this.#scaleTimeoutId = null;
;// CONCATENATED MODULE: ./web/secondary_toolbar.js
constructor(options, eventBus) {
element: options.presentationModeButton,
eventName: "presentationmode",
element: options.printButton,
element: options.downloadButton,
element: options.viewBookmarkButton,
element: options.firstPageButton,
element: options.lastPageButton,
element: options.pageRotateCwButton,
element: options.pageRotateCcwButton,
element: options.cursorSelectToolButton,
eventName: "switchcursortool",