Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/embedpre.../assets/pdf/web
File: viewer.js
#altTextManager = null;
[14000] Fix | Delete
#annotationEditorHighlightColors = null;
[14001] Fix | Delete
#annotationEditorMode = AnnotationEditorType.NONE;
[14002] Fix | Delete
#annotationEditorUIManager = null;
[14003] Fix | Delete
#annotationMode = AnnotationMode.ENABLE_FORMS;
[14004] Fix | Delete
#containerTopLeft = null;
[14005] Fix | Delete
#enableHighlightFloatingButton = false;
[14006] Fix | Delete
#enablePermissions = false;
[14007] Fix | Delete
#eventAbortController = null;
[14008] Fix | Delete
#mlManager = null;
[14009] Fix | Delete
#getAllTextInProgress = false;
[14010] Fix | Delete
#hiddenCopyElement = null;
[14011] Fix | Delete
#interruptCopyCondition = false;
[14012] Fix | Delete
#previousContainerHeight = 0;
[14013] Fix | Delete
#resizeObserver = new ResizeObserver(this.#resizeObserverCallback.bind(this));
[14014] Fix | Delete
#scrollModePageState = null;
[14015] Fix | Delete
#scaleTimeoutId = null;
[14016] Fix | Delete
#textLayerMode = TextLayerMode.ENABLE;
[14017] Fix | Delete
constructor(options) {
[14018] Fix | Delete
const viewerVersion = "4.3.136";
[14019] Fix | Delete
if (version !== viewerVersion) {
[14020] Fix | Delete
throw new Error(`The API version "${version}" does not match the Viewer version "${viewerVersion}".`);
[14021] Fix | Delete
}
[14022] Fix | Delete
this.container = options.container;
[14023] Fix | Delete
this.viewer = options.viewer || options.container.firstElementChild;
[14024] Fix | Delete
if (this.container?.tagName !== "DIV" || this.viewer?.tagName !== "DIV") {
[14025] Fix | Delete
throw new Error("Invalid `container` and/or `viewer` option.");
[14026] Fix | Delete
}
[14027] Fix | Delete
if (this.container.offsetParent && getComputedStyle(this.container).position !== "absolute") {
[14028] Fix | Delete
throw new Error("The `container` must be absolutely positioned.");
[14029] Fix | Delete
}
[14030] Fix | Delete
this.#resizeObserver.observe(this.container);
[14031] Fix | Delete
this.eventBus = options.eventBus;
[14032] Fix | Delete
this.linkService = options.linkService || new SimpleLinkService();
[14033] Fix | Delete
this.downloadManager = options.downloadManager || null;
[14034] Fix | Delete
this.findController = options.findController || null;
[14035] Fix | Delete
this.#altTextManager = options.altTextManager || null;
[14036] Fix | Delete
if (this.findController) {
[14037] Fix | Delete
this.findController.onIsPageVisible = pageNumber => this._getVisiblePages().ids.has(pageNumber);
[14038] Fix | Delete
}
[14039] Fix | Delete
this._scriptingManager = options.scriptingManager || null;
[14040] Fix | Delete
this.#textLayerMode = options.textLayerMode ?? TextLayerMode.ENABLE;
[14041] Fix | Delete
this.#annotationMode = options.annotationMode ?? AnnotationMode.ENABLE_FORMS;
[14042] Fix | Delete
this.#annotationEditorMode = options.annotationEditorMode ?? AnnotationEditorType.NONE;
[14043] Fix | Delete
this.#annotationEditorHighlightColors = options.annotationEditorHighlightColors || null;
[14044] Fix | Delete
this.#enableHighlightFloatingButton = options.enableHighlightFloatingButton === true;
[14045] Fix | Delete
this.imageResourcesPath = options.imageResourcesPath || "";
[14046] Fix | Delete
this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
[14047] Fix | Delete
this.removePageBorders = options.removePageBorders || false;
[14048] Fix | Delete
this.maxCanvasPixels = options.maxCanvasPixels;
[14049] Fix | Delete
this.l10n = options.l10n;
[14050] Fix | Delete
this.l10n ||= new genericl10n_GenericL10n();
[14051] Fix | Delete
this.#enablePermissions = options.enablePermissions || false;
[14052] Fix | Delete
this.pageColors = options.pageColors || null;
[14053] Fix | Delete
this.#mlManager = options.mlManager || null;
[14054] Fix | Delete
this.defaultRenderingQueue = !options.renderingQueue;
[14055] Fix | Delete
if (this.defaultRenderingQueue) {
[14056] Fix | Delete
this.renderingQueue = new PDFRenderingQueue();
[14057] Fix | Delete
this.renderingQueue.setViewer(this);
[14058] Fix | Delete
} else {
[14059] Fix | Delete
this.renderingQueue = options.renderingQueue;
[14060] Fix | Delete
}
[14061] Fix | Delete
this.scroll = watchScroll(this.container, this._scrollUpdate.bind(this));
[14062] Fix | Delete
this.presentationModeState = PresentationModeState.UNKNOWN;
[14063] Fix | Delete
this._resetView();
[14064] Fix | Delete
if (this.removePageBorders) {
[14065] Fix | Delete
this.viewer.classList.add("removePageBorders");
[14066] Fix | Delete
}
[14067] Fix | Delete
this.#updateContainerHeightCss();
[14068] Fix | Delete
this.eventBus._on("thumbnailrendered", ({
[14069] Fix | Delete
pageNumber,
[14070] Fix | Delete
pdfPage
[14071] Fix | Delete
}) => {
[14072] Fix | Delete
const pageView = this._pages[pageNumber - 1];
[14073] Fix | Delete
if (!this.#buffer.has(pageView)) {
[14074] Fix | Delete
pdfPage?.cleanup();
[14075] Fix | Delete
}
[14076] Fix | Delete
});
[14077] Fix | Delete
if (!options.l10n) {
[14078] Fix | Delete
this.l10n.translate(this.container);
[14079] Fix | Delete
}
[14080] Fix | Delete
}
[14081] Fix | Delete
get pagesCount() {
[14082] Fix | Delete
return this._pages.length;
[14083] Fix | Delete
}
[14084] Fix | Delete
getPageView(index) {
[14085] Fix | Delete
return this._pages[index];
[14086] Fix | Delete
}
[14087] Fix | Delete
getCachedPageViews() {
[14088] Fix | Delete
return new Set(this.#buffer);
[14089] Fix | Delete
}
[14090] Fix | Delete
get pageViewsReady() {
[14091] Fix | Delete
return this._pages.every(pageView => pageView?.pdfPage);
[14092] Fix | Delete
}
[14093] Fix | Delete
get renderForms() {
[14094] Fix | Delete
return this.#annotationMode === AnnotationMode.ENABLE_FORMS;
[14095] Fix | Delete
}
[14096] Fix | Delete
get enableScripting() {
[14097] Fix | Delete
return !!this._scriptingManager;
[14098] Fix | Delete
}
[14099] Fix | Delete
get currentPageNumber() {
[14100] Fix | Delete
return this._currentPageNumber;
[14101] Fix | Delete
}
[14102] Fix | Delete
set currentPageNumber(val) {
[14103] Fix | Delete
if (!Number.isInteger(val)) {
[14104] Fix | Delete
throw new Error("Invalid page number.");
[14105] Fix | Delete
}
[14106] Fix | Delete
if (!this.pdfDocument) {
[14107] Fix | Delete
return;
[14108] Fix | Delete
}
[14109] Fix | Delete
if (!this._setCurrentPageNumber(val, true)) {
[14110] Fix | Delete
console.error(`currentPageNumber: "${val}" is not a valid page.`);
[14111] Fix | Delete
}
[14112] Fix | Delete
}
[14113] Fix | Delete
_setCurrentPageNumber(val, resetCurrentPageView = false) {
[14114] Fix | Delete
if (this._currentPageNumber === val) {
[14115] Fix | Delete
if (resetCurrentPageView) {
[14116] Fix | Delete
this.#resetCurrentPageView();
[14117] Fix | Delete
}
[14118] Fix | Delete
return true;
[14119] Fix | Delete
}
[14120] Fix | Delete
if (!(0 < val && val <= this.pagesCount)) {
[14121] Fix | Delete
return false;
[14122] Fix | Delete
}
[14123] Fix | Delete
const previous = this._currentPageNumber;
[14124] Fix | Delete
this._currentPageNumber = val;
[14125] Fix | Delete
this.eventBus.dispatch("pagechanging", {
[14126] Fix | Delete
source: this,
[14127] Fix | Delete
pageNumber: val,
[14128] Fix | Delete
pageLabel: this._pageLabels?.[val - 1] ?? null,
[14129] Fix | Delete
previous
[14130] Fix | Delete
});
[14131] Fix | Delete
if (resetCurrentPageView) {
[14132] Fix | Delete
this.#resetCurrentPageView();
[14133] Fix | Delete
}
[14134] Fix | Delete
return true;
[14135] Fix | Delete
}
[14136] Fix | Delete
get currentPageLabel() {
[14137] Fix | Delete
return this._pageLabels?.[this._currentPageNumber - 1] ?? null;
[14138] Fix | Delete
}
[14139] Fix | Delete
set currentPageLabel(val) {
[14140] Fix | Delete
if (!this.pdfDocument) {
[14141] Fix | Delete
return;
[14142] Fix | Delete
}
[14143] Fix | Delete
let page = val | 0;
[14144] Fix | Delete
if (this._pageLabels) {
[14145] Fix | Delete
const i = this._pageLabels.indexOf(val);
[14146] Fix | Delete
if (i >= 0) {
[14147] Fix | Delete
page = i + 1;
[14148] Fix | Delete
}
[14149] Fix | Delete
}
[14150] Fix | Delete
if (!this._setCurrentPageNumber(page, true)) {
[14151] Fix | Delete
console.error(`currentPageLabel: "${val}" is not a valid page.`);
[14152] Fix | Delete
}
[14153] Fix | Delete
}
[14154] Fix | Delete
get currentScale() {
[14155] Fix | Delete
return this._currentScale !== UNKNOWN_SCALE ? this._currentScale : DEFAULT_SCALE;
[14156] Fix | Delete
}
[14157] Fix | Delete
set currentScale(val) {
[14158] Fix | Delete
if (isNaN(val)) {
[14159] Fix | Delete
throw new Error("Invalid numeric scale.");
[14160] Fix | Delete
}
[14161] Fix | Delete
if (!this.pdfDocument) {
[14162] Fix | Delete
return;
[14163] Fix | Delete
}
[14164] Fix | Delete
this.#setScale(val, {
[14165] Fix | Delete
noScroll: false
[14166] Fix | Delete
});
[14167] Fix | Delete
}
[14168] Fix | Delete
get currentScaleValue() {
[14169] Fix | Delete
return this._currentScaleValue;
[14170] Fix | Delete
}
[14171] Fix | Delete
set currentScaleValue(val) {
[14172] Fix | Delete
if (!this.pdfDocument) {
[14173] Fix | Delete
return;
[14174] Fix | Delete
}
[14175] Fix | Delete
this.#setScale(val, {
[14176] Fix | Delete
noScroll: false
[14177] Fix | Delete
});
[14178] Fix | Delete
}
[14179] Fix | Delete
get pagesRotation() {
[14180] Fix | Delete
return this._pagesRotation;
[14181] Fix | Delete
}
[14182] Fix | Delete
set pagesRotation(rotation) {
[14183] Fix | Delete
if (!isValidRotation(rotation)) {
[14184] Fix | Delete
throw new Error("Invalid pages rotation angle.");
[14185] Fix | Delete
}
[14186] Fix | Delete
if (!this.pdfDocument) {
[14187] Fix | Delete
return;
[14188] Fix | Delete
}
[14189] Fix | Delete
rotation %= 360;
[14190] Fix | Delete
if (rotation < 0) {
[14191] Fix | Delete
rotation += 360;
[14192] Fix | Delete
}
[14193] Fix | Delete
if (this._pagesRotation === rotation) {
[14194] Fix | Delete
return;
[14195] Fix | Delete
}
[14196] Fix | Delete
this._pagesRotation = rotation;
[14197] Fix | Delete
const pageNumber = this._currentPageNumber;
[14198] Fix | Delete
this.refresh(true, {
[14199] Fix | Delete
rotation
[14200] Fix | Delete
});
[14201] Fix | Delete
if (this._currentScaleValue) {
[14202] Fix | Delete
this.#setScale(this._currentScaleValue, {
[14203] Fix | Delete
noScroll: true
[14204] Fix | Delete
});
[14205] Fix | Delete
}
[14206] Fix | Delete
this.eventBus.dispatch("rotationchanging", {
[14207] Fix | Delete
source: this,
[14208] Fix | Delete
pagesRotation: rotation,
[14209] Fix | Delete
pageNumber
[14210] Fix | Delete
});
[14211] Fix | Delete
if (this.defaultRenderingQueue) {
[14212] Fix | Delete
this.update();
[14213] Fix | Delete
}
[14214] Fix | Delete
}
[14215] Fix | Delete
get firstPagePromise() {
[14216] Fix | Delete
return this.pdfDocument ? this._firstPageCapability.promise : null;
[14217] Fix | Delete
}
[14218] Fix | Delete
get onePageRendered() {
[14219] Fix | Delete
return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
[14220] Fix | Delete
}
[14221] Fix | Delete
get pagesPromise() {
[14222] Fix | Delete
return this.pdfDocument ? this._pagesCapability.promise : null;
[14223] Fix | Delete
}
[14224] Fix | Delete
get _layerProperties() {
[14225] Fix | Delete
const self = this;
[14226] Fix | Delete
return shadow(this, "_layerProperties", {
[14227] Fix | Delete
get annotationEditorUIManager() {
[14228] Fix | Delete
return self.#annotationEditorUIManager;
[14229] Fix | Delete
},
[14230] Fix | Delete
get annotationStorage() {
[14231] Fix | Delete
return self.pdfDocument?.annotationStorage;
[14232] Fix | Delete
},
[14233] Fix | Delete
get downloadManager() {
[14234] Fix | Delete
return self.downloadManager;
[14235] Fix | Delete
},
[14236] Fix | Delete
get enableScripting() {
[14237] Fix | Delete
return !!self._scriptingManager;
[14238] Fix | Delete
},
[14239] Fix | Delete
get fieldObjectsPromise() {
[14240] Fix | Delete
return self.pdfDocument?.getFieldObjects();
[14241] Fix | Delete
},
[14242] Fix | Delete
get findController() {
[14243] Fix | Delete
return self.findController;
[14244] Fix | Delete
},
[14245] Fix | Delete
get hasJSActionsPromise() {
[14246] Fix | Delete
return self.pdfDocument?.hasJSActions();
[14247] Fix | Delete
},
[14248] Fix | Delete
get linkService() {
[14249] Fix | Delete
return self.linkService;
[14250] Fix | Delete
}
[14251] Fix | Delete
});
[14252] Fix | Delete
}
[14253] Fix | Delete
#initializePermissions(permissions) {
[14254] Fix | Delete
const params = {
[14255] Fix | Delete
annotationEditorMode: this.#annotationEditorMode,
[14256] Fix | Delete
annotationMode: this.#annotationMode,
[14257] Fix | Delete
textLayerMode: this.#textLayerMode
[14258] Fix | Delete
};
[14259] Fix | Delete
if (!permissions) {
[14260] Fix | Delete
return params;
[14261] Fix | Delete
}
[14262] Fix | Delete
if (!permissions.includes(PermissionFlag.COPY) && this.#textLayerMode === TextLayerMode.ENABLE) {
[14263] Fix | Delete
params.textLayerMode = TextLayerMode.ENABLE_PERMISSIONS;
[14264] Fix | Delete
}
[14265] Fix | Delete
if (!permissions.includes(PermissionFlag.MODIFY_CONTENTS)) {
[14266] Fix | Delete
params.annotationEditorMode = AnnotationEditorType.DISABLE;
[14267] Fix | Delete
}
[14268] Fix | Delete
if (!permissions.includes(PermissionFlag.MODIFY_ANNOTATIONS) && !permissions.includes(PermissionFlag.FILL_INTERACTIVE_FORMS) && this.#annotationMode === AnnotationMode.ENABLE_FORMS) {
[14269] Fix | Delete
params.annotationMode = AnnotationMode.ENABLE;
[14270] Fix | Delete
}
[14271] Fix | Delete
return params;
[14272] Fix | Delete
}
[14273] Fix | Delete
async #onePageRenderedOrForceFetch(signal) {
[14274] Fix | Delete
if (document.visibilityState === "hidden" || !this.container.offsetParent || this._getVisiblePages().views.length === 0) {
[14275] Fix | Delete
return;
[14276] Fix | Delete
}
[14277] Fix | Delete
const hiddenCapability = Promise.withResolvers();
[14278] Fix | Delete
function onVisibilityChange() {
[14279] Fix | Delete
if (document.visibilityState === "hidden") {
[14280] Fix | Delete
hiddenCapability.resolve();
[14281] Fix | Delete
}
[14282] Fix | Delete
}
[14283] Fix | Delete
document.addEventListener("visibilitychange", onVisibilityChange, {
[14284] Fix | Delete
signal
[14285] Fix | Delete
});
[14286] Fix | Delete
await Promise.race([this._onePageRenderedCapability.promise, hiddenCapability.promise]);
[14287] Fix | Delete
document.removeEventListener("visibilitychange", onVisibilityChange);
[14288] Fix | Delete
}
[14289] Fix | Delete
async getAllText() {
[14290] Fix | Delete
const texts = [];
[14291] Fix | Delete
const buffer = [];
[14292] Fix | Delete
for (let pageNum = 1, pagesCount = this.pdfDocument.numPages; pageNum <= pagesCount; ++pageNum) {
[14293] Fix | Delete
if (this.#interruptCopyCondition) {
[14294] Fix | Delete
return null;
[14295] Fix | Delete
}
[14296] Fix | Delete
buffer.length = 0;
[14297] Fix | Delete
const page = await this.pdfDocument.getPage(pageNum);
[14298] Fix | Delete
const {
[14299] Fix | Delete
items
[14300] Fix | Delete
} = await page.getTextContent();
[14301] Fix | Delete
for (const item of items) {
[14302] Fix | Delete
if (item.str) {
[14303] Fix | Delete
buffer.push(item.str);
[14304] Fix | Delete
}
[14305] Fix | Delete
if (item.hasEOL) {
[14306] Fix | Delete
buffer.push("\n");
[14307] Fix | Delete
}
[14308] Fix | Delete
}
[14309] Fix | Delete
texts.push(removeNullCharacters(buffer.join("")));
[14310] Fix | Delete
}
[14311] Fix | Delete
return texts.join("\n");
[14312] Fix | Delete
}
[14313] Fix | Delete
#copyCallback(textLayerMode, event) {
[14314] Fix | Delete
const selection = document.getSelection();
[14315] Fix | Delete
const {
[14316] Fix | Delete
focusNode,
[14317] Fix | Delete
anchorNode
[14318] Fix | Delete
} = selection;
[14319] Fix | Delete
if (anchorNode && focusNode && selection.containsNode(this.#hiddenCopyElement)) {
[14320] Fix | Delete
if (this.#getAllTextInProgress || textLayerMode === TextLayerMode.ENABLE_PERMISSIONS) {
[14321] Fix | Delete
event.preventDefault();
[14322] Fix | Delete
event.stopPropagation();
[14323] Fix | Delete
return;
[14324] Fix | Delete
}
[14325] Fix | Delete
this.#getAllTextInProgress = true;
[14326] Fix | Delete
const savedCursor = this.container.style.cursor;
[14327] Fix | Delete
this.container.style.cursor = "wait";
[14328] Fix | Delete
const interruptCopy = ev => this.#interruptCopyCondition = ev.key === "Escape";
[14329] Fix | Delete
window.addEventListener("keydown", interruptCopy);
[14330] Fix | Delete
this.getAllText().then(async text => {
[14331] Fix | Delete
if (text !== null) {
[14332] Fix | Delete
await navigator.clipboard.writeText(text);
[14333] Fix | Delete
}
[14334] Fix | Delete
}).catch(reason => {
[14335] Fix | Delete
console.warn(`Something goes wrong when extracting the text: ${reason.message}`);
[14336] Fix | Delete
}).finally(() => {
[14337] Fix | Delete
this.#getAllTextInProgress = false;
[14338] Fix | Delete
this.#interruptCopyCondition = false;
[14339] Fix | Delete
window.removeEventListener("keydown", interruptCopy);
[14340] Fix | Delete
this.container.style.cursor = savedCursor;
[14341] Fix | Delete
});
[14342] Fix | Delete
event.preventDefault();
[14343] Fix | Delete
event.stopPropagation();
[14344] Fix | Delete
}
[14345] Fix | Delete
}
[14346] Fix | Delete
setDocument(pdfDocument) {
[14347] Fix | Delete
if (this.pdfDocument) {
[14348] Fix | Delete
this.eventBus.dispatch("pagesdestroy", {
[14349] Fix | Delete
source: this
[14350] Fix | Delete
});
[14351] Fix | Delete
this._cancelRendering();
[14352] Fix | Delete
this._resetView();
[14353] Fix | Delete
this.findController?.setDocument(null);
[14354] Fix | Delete
this._scriptingManager?.setDocument(null);
[14355] Fix | Delete
if (this.#annotationEditorUIManager) {
[14356] Fix | Delete
this.#annotationEditorUIManager.destroy();
[14357] Fix | Delete
this.#annotationEditorUIManager = null;
[14358] Fix | Delete
}
[14359] Fix | Delete
}
[14360] Fix | Delete
this.pdfDocument = pdfDocument;
[14361] Fix | Delete
if (!pdfDocument) {
[14362] Fix | Delete
return;
[14363] Fix | Delete
}
[14364] Fix | Delete
const pagesCount = pdfDocument.numPages;
[14365] Fix | Delete
const firstPagePromise = pdfDocument.getPage(1);
[14366] Fix | Delete
const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig({
[14367] Fix | Delete
intent: "display"
[14368] Fix | Delete
});
[14369] Fix | Delete
const permissionsPromise = this.#enablePermissions ? pdfDocument.getPermissions() : Promise.resolve();
[14370] Fix | Delete
const {
[14371] Fix | Delete
eventBus,
[14372] Fix | Delete
pageColors,
[14373] Fix | Delete
viewer
[14374] Fix | Delete
} = this;
[14375] Fix | Delete
this.#eventAbortController = new AbortController();
[14376] Fix | Delete
const {
[14377] Fix | Delete
signal
[14378] Fix | Delete
} = this.#eventAbortController;
[14379] Fix | Delete
if (pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
[14380] Fix | Delete
console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");
[14381] Fix | Delete
const mode = this._scrollMode = ScrollMode.PAGE;
[14382] Fix | Delete
eventBus.dispatch("scrollmodechanged", {
[14383] Fix | Delete
source: this,
[14384] Fix | Delete
mode
[14385] Fix | Delete
});
[14386] Fix | Delete
}
[14387] Fix | Delete
this._pagesCapability.promise.then(() => {
[14388] Fix | Delete
eventBus.dispatch("pagesloaded", {
[14389] Fix | Delete
source: this,
[14390] Fix | Delete
pagesCount
[14391] Fix | Delete
});
[14392] Fix | Delete
}, () => {});
[14393] Fix | Delete
const onBeforeDraw = evt => {
[14394] Fix | Delete
const pageView = this._pages[evt.pageNumber - 1];
[14395] Fix | Delete
if (!pageView) {
[14396] Fix | Delete
return;
[14397] Fix | Delete
}
[14398] Fix | Delete
this.#buffer.push(pageView);
[14399] Fix | Delete
};
[14400] Fix | Delete
eventBus._on("pagerender", onBeforeDraw, {
[14401] Fix | Delete
signal
[14402] Fix | Delete
});
[14403] Fix | Delete
const onAfterDraw = evt => {
[14404] Fix | Delete
if (evt.cssTransform) {
[14405] Fix | Delete
return;
[14406] Fix | Delete
}
[14407] Fix | Delete
this._onePageRenderedCapability.resolve({
[14408] Fix | Delete
timestamp: evt.timestamp
[14409] Fix | Delete
});
[14410] Fix | Delete
eventBus._off("pagerendered", onAfterDraw);
[14411] Fix | Delete
};
[14412] Fix | Delete
eventBus._on("pagerendered", onAfterDraw, {
[14413] Fix | Delete
signal
[14414] Fix | Delete
});
[14415] Fix | Delete
Promise.all([firstPagePromise, permissionsPromise]).then(([firstPdfPage, permissions]) => {
[14416] Fix | Delete
if (pdfDocument !== this.pdfDocument) {
[14417] Fix | Delete
return;
[14418] Fix | Delete
}
[14419] Fix | Delete
this._firstPageCapability.resolve(firstPdfPage);
[14420] Fix | Delete
this._optionalContentConfigPromise = optionalContentConfigPromise;
[14421] Fix | Delete
const {
[14422] Fix | Delete
annotationEditorMode,
[14423] Fix | Delete
annotationMode,
[14424] Fix | Delete
textLayerMode
[14425] Fix | Delete
} = this.#initializePermissions(permissions);
[14426] Fix | Delete
if (textLayerMode !== TextLayerMode.DISABLE) {
[14427] Fix | Delete
const element = this.#hiddenCopyElement = document.createElement("div");
[14428] Fix | Delete
element.id = "hiddenCopyElement";
[14429] Fix | Delete
viewer.before(element);
[14430] Fix | Delete
}
[14431] Fix | Delete
if (annotationEditorMode !== AnnotationEditorType.DISABLE) {
[14432] Fix | Delete
const mode = annotationEditorMode;
[14433] Fix | Delete
if (pdfDocument.isPureXfa) {
[14434] Fix | Delete
console.warn("Warning: XFA-editing is not implemented.");
[14435] Fix | Delete
} else if (isValidAnnotationEditorMode(mode)) {
[14436] Fix | Delete
this.#annotationEditorUIManager = new AnnotationEditorUIManager(this.container, viewer, this.#altTextManager, eventBus, pdfDocument, pageColors, this.#annotationEditorHighlightColors, this.#enableHighlightFloatingButton, this.#mlManager);
[14437] Fix | Delete
eventBus.dispatch("annotationeditoruimanager", {
[14438] Fix | Delete
source: this,
[14439] Fix | Delete
uiManager: this.#annotationEditorUIManager
[14440] Fix | Delete
});
[14441] Fix | Delete
if (mode !== AnnotationEditorType.NONE) {
[14442] Fix | Delete
this.#annotationEditorUIManager.updateMode(mode);
[14443] Fix | Delete
}
[14444] Fix | Delete
} else {
[14445] Fix | Delete
console.error(`Invalid AnnotationEditor mode: ${mode}`);
[14446] Fix | Delete
}
[14447] Fix | Delete
}
[14448] Fix | Delete
const viewerElement = this._scrollMode === ScrollMode.PAGE ? null : viewer;
[14449] Fix | Delete
const scale = this.currentScale;
[14450] Fix | Delete
const viewport = firstPdfPage.getViewport({
[14451] Fix | Delete
scale: scale * PixelsPerInch.PDF_TO_CSS_UNITS
[14452] Fix | Delete
});
[14453] Fix | Delete
viewer.style.setProperty("--scale-factor", viewport.scale);
[14454] Fix | Delete
if (pageColors?.foreground === "CanvasText" || pageColors?.background === "Canvas") {
[14455] Fix | Delete
viewer.style.setProperty("--hcm-highlight-filter", pdfDocument.filterFactory.addHighlightHCMFilter("highlight", "CanvasText", "Canvas", "HighlightText", "Highlight"));
[14456] Fix | Delete
viewer.style.setProperty("--hcm-highlight-selected-filter", pdfDocument.filterFactory.addHighlightHCMFilter("highlight_selected", "CanvasText", "Canvas", "HighlightText", "ButtonText"));
[14457] Fix | Delete
}
[14458] Fix | Delete
for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
[14459] Fix | Delete
const pageView = new PDFPageView({
[14460] Fix | Delete
container: viewerElement,
[14461] Fix | Delete
eventBus,
[14462] Fix | Delete
id: pageNum,
[14463] Fix | Delete
scale,
[14464] Fix | Delete
defaultViewport: viewport.clone(),
[14465] Fix | Delete
optionalContentConfigPromise,
[14466] Fix | Delete
renderingQueue: this.renderingQueue,
[14467] Fix | Delete
textLayerMode,
[14468] Fix | Delete
annotationMode,
[14469] Fix | Delete
imageResourcesPath: this.imageResourcesPath,
[14470] Fix | Delete
maxCanvasPixels: this.maxCanvasPixels,
[14471] Fix | Delete
pageColors,
[14472] Fix | Delete
l10n: this.l10n,
[14473] Fix | Delete
layerProperties: this._layerProperties
[14474] Fix | Delete
});
[14475] Fix | Delete
this._pages.push(pageView);
[14476] Fix | Delete
}
[14477] Fix | Delete
this._pages[0]?.setPdfPage(firstPdfPage);
[14478] Fix | Delete
if (this._scrollMode === ScrollMode.PAGE) {
[14479] Fix | Delete
this.#ensurePageViewVisible();
[14480] Fix | Delete
} else if (this._spreadMode !== SpreadMode.NONE) {
[14481] Fix | Delete
this._updateSpreadMode();
[14482] Fix | Delete
}
[14483] Fix | Delete
this.#onePageRenderedOrForceFetch(signal).then(async () => {
[14484] Fix | Delete
if (pdfDocument !== this.pdfDocument) {
[14485] Fix | Delete
return;
[14486] Fix | Delete
}
[14487] Fix | Delete
this.findController?.setDocument(pdfDocument);
[14488] Fix | Delete
this._scriptingManager?.setDocument(pdfDocument);
[14489] Fix | Delete
if (this.#hiddenCopyElement) {
[14490] Fix | Delete
document.addEventListener("copy", this.#copyCallback.bind(this, textLayerMode), {
[14491] Fix | Delete
signal
[14492] Fix | Delete
});
[14493] Fix | Delete
}
[14494] Fix | Delete
if (this.#annotationEditorUIManager) {
[14495] Fix | Delete
eventBus.dispatch("annotationeditormodechanged", {
[14496] Fix | Delete
source: this,
[14497] Fix | Delete
mode: this.#annotationEditorMode
[14498] Fix | Delete
});
[14499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function