Bug 1704661 - Update pdf.js to version 2.9.44 r=calixte

Differential Revision: https://phabricator.services.mozilla.com/D111747
This commit is contained in:
Brendan Dahl 2021-04-14 01:38:01 +00:00
Родитель f6d17a387d
Коммит b19a3f2246
9 изменённых файлов: 1726 добавлений и 629 удалений

Просмотреть файл

@ -15,5 +15,6 @@
# Chrome notification bar messages and buttons # Chrome notification bar messages and buttons
unsupported_feature=This PDF document might not be displayed correctly. unsupported_feature=This PDF document might not be displayed correctly.
unsupported_feature_forms=This PDF document contains forms. The filling of form fields is not supported. unsupported_feature_forms=This PDF document contains forms. The filling of form fields is not supported.
unsupported_feature_signatures=This PDF document contains digital signatures. Validation of signatures is not supported.
open_with_different_viewer=Open With Different Viewer open_with_different_viewer=Open With Different Viewer
open_with_different_viewer.accessKey=o open_with_different_viewer.accessKey=o

Просмотреть файл

@ -246,3 +246,6 @@ password_cancel=Cancel
printing_not_supported=Warning: Printing is not fully supported by this browser. printing_not_supported=Warning: Printing is not fully supported by this browser.
printing_not_ready=Warning: The PDF is not fully loaded for printing. printing_not_ready=Warning: The PDF is not fully loaded for printing.
web_fonts_disabled=Web fonts are disabled: unable to use embedded PDF fonts. web_fonts_disabled=Web fonts are disabled: unable to use embedded PDF fonts.
# LOCALIZATION NOTE (unsupported_feature_signatures): Should contain the same
# exact string as in the `chrome.properties` file.
unsupported_feature_signatures=This PDF document contains digital signatures. Validation of signatures is not supported.

Просмотреть файл

@ -1,5 +1,5 @@
This is the PDF.js project output, https://github.com/mozilla/pdf.js This is the PDF.js project output, https://github.com/mozilla/pdf.js
Current extension version is: 2.8.320 Current extension version is: 2.9.44
Taken from upstream commit: ca7f54682 Taken from upstream commit: 6cf307000

Просмотреть файл

@ -926,6 +926,7 @@ const UNSUPPORTED_FEATURES = {
unknown: "unknown", unknown: "unknown",
forms: "forms", forms: "forms",
javaScript: "javaScript", javaScript: "javaScript",
signatures: "signatures",
smask: "smask", smask: "smask",
shadingPattern: "shadingPattern", shadingPattern: "shadingPattern",
font: "font", font: "font",
@ -1752,7 +1753,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
return worker.messageHandler.sendWithPromise("GetDocRequest", { return worker.messageHandler.sendWithPromise("GetDocRequest", {
docId, docId,
apiVersion: '2.8.320', apiVersion: '2.9.44',
source: { source: {
data: source.data, data: source.data,
url: source.url, url: source.url,
@ -1896,7 +1897,7 @@ class PDFDocumentProxy {
} }
get annotationStorage() { get annotationStorage() {
return (0, _util.shadow)(this, "annotationStorage", new _annotation_storage.AnnotationStorage()); return this._transport.annotationStorage;
} }
get numPages() { get numPages() {
@ -1991,8 +1992,8 @@ class PDFDocumentProxy {
return this._transport.getStats(); return this._transport.getStats();
} }
cleanup() { cleanup(keepLoadedFonts = false) {
return this._transport.startCleanup(); return this._transport.startCleanup(keepLoadedFonts || this.isPureXfa);
} }
destroy() { destroy() {
@ -2007,8 +2008,8 @@ class PDFDocumentProxy {
return this._transport.loadingTask; return this._transport.loadingTask;
} }
saveDocument(annotationStorage) { saveDocument() {
return this._transport.saveDocument(annotationStorage); return this._transport.saveDocument();
} }
getFieldObjects() { getFieldObjects() {
@ -2083,12 +2084,12 @@ class PDFPageProxy {
getAnnotations({ getAnnotations({
intent = null intent = null
} = {}) { } = {}) {
if (!this.annotationsPromise || this.annotationsIntent !== intent) { if (!this._annotationsPromise || this._annotationsIntent !== intent) {
this.annotationsPromise = this._transport.getAnnotations(this._pageIndex, intent); this._annotationsPromise = this._transport.getAnnotations(this._pageIndex, intent);
this.annotationsIntent = intent; this._annotationsIntent = intent;
} }
return this.annotationsPromise; return this._annotationsPromise;
} }
getJSActions() { getJSActions() {
@ -2109,7 +2110,7 @@ class PDFPageProxy {
imageLayer = null, imageLayer = null,
canvasFactory = null, canvasFactory = null,
background = null, background = null,
annotationStorage = null, includeAnnotationStorage = false,
optionalContentConfigPromise = null optionalContentConfigPromise = null
}) { }) {
if (this._stats) { if (this._stats) {
@ -2142,6 +2143,7 @@ class PDFPageProxy {
const webGLContext = new _webgl.WebGLContext({ const webGLContext = new _webgl.WebGLContext({
enable: enableWebGL enable: enableWebGL
}); });
const annotationStorage = includeAnnotationStorage ? this._transport.annotationStorage.serializable : null;
if (!intentState.displayReadyCapability) { if (!intentState.displayReadyCapability) {
intentState.displayReadyCapability = (0, _util.createPromiseCapability)(); intentState.displayReadyCapability = (0, _util.createPromiseCapability)();
@ -2159,16 +2161,12 @@ class PDFPageProxy {
pageIndex: this._pageIndex, pageIndex: this._pageIndex,
intent: renderingIntent, intent: renderingIntent,
renderInteractiveForms: renderInteractiveForms === true, renderInteractiveForms: renderInteractiveForms === true,
annotationStorage: annotationStorage?.serializable || null annotationStorage
}); });
} }
const complete = error => { const complete = error => {
const i = intentState.renderTasks.indexOf(internalRenderTask); intentState.renderTasks.delete(internalRenderTask);
if (i >= 0) {
intentState.renderTasks.splice(i, 1);
}
if (this.cleanupAfterRender || renderingIntent === "print") { if (this.cleanupAfterRender || renderingIntent === "print") {
this.pendingCleanup = true; this.pendingCleanup = true;
@ -2212,12 +2210,7 @@ class PDFPageProxy {
useRequestAnimationFrame: renderingIntent !== "print", useRequestAnimationFrame: renderingIntent !== "print",
pdfBug: this._pdfBug pdfBug: this._pdfBug
}); });
(intentState.renderTasks ||= new Set()).add(internalRenderTask);
if (!intentState.renderTasks) {
intentState.renderTasks = [];
}
intentState.renderTasks.push(internalRenderTask);
const renderTask = internalRenderTask.task; const renderTask = internalRenderTask.task;
Promise.all([intentState.displayReadyCapability.promise, optionalContentConfigPromise]).then(([transparency, optionalContentConfig]) => { Promise.all([intentState.displayReadyCapability.promise, optionalContentConfigPromise]).then(([transparency, optionalContentConfig]) => {
if (this.pendingCleanup) { if (this.pendingCleanup) {
@ -2242,11 +2235,7 @@ class PDFPageProxy {
function operatorListChanged() { function operatorListChanged() {
if (intentState.operatorList.lastChunk) { if (intentState.operatorList.lastChunk) {
intentState.opListReadCapability.resolve(intentState.operatorList); intentState.opListReadCapability.resolve(intentState.operatorList);
const i = intentState.renderTasks.indexOf(opListTask); intentState.renderTasks.delete(opListTask);
if (i >= 0) {
intentState.renderTasks.splice(i, 1);
}
} }
} }
@ -2266,8 +2255,7 @@ class PDFPageProxy {
opListTask = Object.create(null); opListTask = Object.create(null);
opListTask.operatorListChanged = operatorListChanged; opListTask.operatorListChanged = operatorListChanged;
intentState.opListReadCapability = (0, _util.createPromiseCapability)(); intentState.opListReadCapability = (0, _util.createPromiseCapability)();
intentState.renderTasks = []; (intentState.renderTasks ||= new Set()).add(opListTask);
intentState.renderTasks.push(opListTask);
intentState.operatorList = { intentState.operatorList = {
fnArray: [], fnArray: [],
argsArray: [], argsArray: [],
@ -2289,13 +2277,15 @@ class PDFPageProxy {
streamTextContent({ streamTextContent({
normalizeWhitespace = false, normalizeWhitespace = false,
disableCombineTextItems = false disableCombineTextItems = false,
includeMarkedContent = false
} = {}) { } = {}) {
const TEXT_CONTENT_CHUNK_SIZE = 100; const TEXT_CONTENT_CHUNK_SIZE = 100;
return this._transport.messageHandler.sendWithStream("GetTextContent", { return this._transport.messageHandler.sendWithStream("GetTextContent", {
pageIndex: this._pageIndex, pageIndex: this._pageIndex,
normalizeWhitespace: normalizeWhitespace === true, normalizeWhitespace: normalizeWhitespace === true,
combineTextItems: disableCombineTextItems !== true combineTextItems: disableCombineTextItems !== true,
includeMarkedContent: includeMarkedContent === true
}, { }, {
highWaterMark: TEXT_CONTENT_CHUNK_SIZE, highWaterMark: TEXT_CONTENT_CHUNK_SIZE,
@ -2334,6 +2324,10 @@ class PDFPageProxy {
}); });
} }
getStructTree() {
return this._structTreePromise ||= this._transport.getStructTree(this._pageIndex);
}
_destroy() { _destroy() {
this.destroyed = true; this.destroyed = true;
this._transport.pageCache[this._pageIndex] = null; this._transport.pageCache[this._pageIndex] = null;
@ -2357,9 +2351,10 @@ class PDFPageProxy {
} }
this.objs.clear(); this.objs.clear();
this.annotationsPromise = null; this._annotationsPromise = null;
this._jsActionsPromise = null; this._jsActionsPromise = null;
this._xfaPromise = null; this._xfaPromise = null;
this._structTreePromise = null;
this.pendingCleanup = false; this.pendingCleanup = false;
return Promise.all(waitOn); return Promise.all(waitOn);
} }
@ -2378,7 +2373,7 @@ class PDFPageProxy {
renderTasks, renderTasks,
operatorList operatorList
} of this._intentStates.values()) { } of this._intentStates.values()) {
if (renderTasks.length !== 0 || !operatorList.lastChunk) { if (renderTasks.size > 0 || !operatorList.lastChunk) {
return false; return false;
} }
} }
@ -2386,9 +2381,10 @@ class PDFPageProxy {
this._intentStates.clear(); this._intentStates.clear();
this.objs.clear(); this.objs.clear();
this.annotationsPromise = null; this._annotationsPromise = null;
this._jsActionsPromise = null; this._jsActionsPromise = null;
this._xfaPromise = null; this._xfaPromise = null;
this._structTreePromise = null;
if (resetStats && this._stats) { if (resetStats && this._stats) {
this._stats = new _display_utils.StatTimer(); this._stats = new _display_utils.StatTimer();
@ -2422,8 +2418,8 @@ class PDFPageProxy {
intentState.operatorList.lastChunk = operatorListChunk.lastChunk; intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
for (let i = 0; i < intentState.renderTasks.length; i++) { for (const internalRenderTask of intentState.renderTasks) {
intentState.renderTasks[i].operatorListChanged(); internalRenderTask.operatorListChanged();
} }
if (operatorListChunk.lastChunk) { if (operatorListChunk.lastChunk) {
@ -2469,8 +2465,8 @@ class PDFPageProxy {
if (intentState.operatorList) { if (intentState.operatorList) {
intentState.operatorList.lastChunk = true; intentState.operatorList.lastChunk = true;
for (let i = 0; i < intentState.renderTasks.length; i++) { for (const internalRenderTask of intentState.renderTasks) {
intentState.renderTasks[i].operatorListChanged(); internalRenderTask.operatorListChanged();
} }
this._tryCleanup(); this._tryCleanup();
@ -2501,7 +2497,7 @@ class PDFPageProxy {
} }
if (!force) { if (!force) {
if (intentState.renderTasks.length !== 0) { if (intentState.renderTasks.size > 0) {
return; return;
} }
@ -2959,8 +2955,8 @@ class WorkerTransport {
this.setupMessageHandler(); this.setupMessageHandler();
} }
get loadingTaskSettled() { get annotationStorage() {
return this.loadingTask._capability.settled; return (0, _util.shadow)(this, "annotationStorage", new _annotation_storage.AnnotationStorage());
} }
destroy() { destroy() {
@ -2983,18 +2979,13 @@ class WorkerTransport {
}); });
this.pageCache.length = 0; this.pageCache.length = 0;
this.pagePromises.length = 0; this.pagePromises.length = 0;
const terminated = this.messageHandler.sendWithPromise("Terminate", null);
waitOn.push(terminated);
if (this.loadingTaskSettled) { if (this.hasOwnProperty("annotationStorage")) {
const annotationStorageResetModified = this.loadingTask.promise.then(pdfDocument => { this.annotationStorage.resetModified();
if (pdfDocument.hasOwnProperty("annotationStorage")) {
pdfDocument.annotationStorage.resetModified();
}
}).catch(() => {});
waitOn.push(annotationStorageResetModified);
} }
const terminated = this.messageHandler.sendWithPromise("Terminate", null);
waitOn.push(terminated);
Promise.all(waitOn).then(() => { Promise.all(waitOn).then(() => {
this.commonObjs.clear(); this.commonObjs.clear();
this.fontLoader.clear(); this.fontLoader.clear();
@ -3388,15 +3379,13 @@ class WorkerTransport {
}); });
} }
saveDocument(annotationStorage) { saveDocument() {
return this.messageHandler.sendWithPromise("SaveDocument", { return this.messageHandler.sendWithPromise("SaveDocument", {
numPages: this._numPages, numPages: this._numPages,
annotationStorage: annotationStorage?.serializable || null, annotationStorage: this.annotationStorage.serializable,
filename: this._fullReader?.filename ?? null filename: this._fullReader?.filename ?? null
}).finally(() => { }).finally(() => {
if (annotationStorage) { this.annotationStorage.resetModified();
annotationStorage.resetModified();
}
}); });
} }
@ -3470,6 +3459,12 @@ class WorkerTransport {
}); });
} }
getStructTree(pageIndex) {
return this.messageHandler.sendWithPromise("GetStructTree", {
pageIndex
});
}
getOutline() { getOutline() {
return this.messageHandler.sendWithPromise("GetOutline", null); return this.messageHandler.sendWithPromise("GetOutline", null);
} }
@ -3503,24 +3498,34 @@ class WorkerTransport {
return this.messageHandler.sendWithPromise("GetStats", null); return this.messageHandler.sendWithPromise("GetStats", null);
} }
startCleanup() { async startCleanup(keepLoadedFonts = false) {
return this.messageHandler.sendWithPromise("Cleanup", null).then(() => { await this.messageHandler.sendWithPromise("Cleanup", null);
for (let i = 0, ii = this.pageCache.length; i < ii; i++) {
const page = this.pageCache[i];
if (page) { if (this.destroyed) {
const cleanupSuccessful = page.cleanup(); return;
}
if (!cleanupSuccessful) { for (let i = 0, ii = this.pageCache.length; i < ii; i++) {
throw new Error(`startCleanup: Page ${i + 1} is currently rendering.`); const page = this.pageCache[i];
}
} if (!page) {
continue;
} }
this.commonObjs.clear(); const cleanupSuccessful = page.cleanup();
if (!cleanupSuccessful) {
throw new Error(`startCleanup: Page ${i + 1} is currently rendering.`);
}
}
this.commonObjs.clear();
if (!keepLoadedFonts) {
this.fontLoader.clear(); this.fontLoader.clear();
this._hasJSActionsPromise = null; }
});
this._hasJSActionsPromise = null;
} }
get loadingParams() { get loadingParams() {
@ -3775,9 +3780,9 @@ const InternalRenderTask = function InternalRenderTaskClosure() {
return InternalRenderTask; return InternalRenderTask;
}(); }();
const version = '2.8.320'; const version = '2.9.44';
exports.version = version; exports.version = version;
const build = 'ca7f54682'; const build = '6cf307000';
exports.build = build; exports.build = build;
/***/ }), /***/ }),
@ -4074,8 +4079,6 @@ Object.defineProperty(exports, "__esModule", ({
})); }));
exports.AnnotationStorage = void 0; exports.AnnotationStorage = void 0;
var _display_utils = __w_pdfjs_require__(1);
var _util = __w_pdfjs_require__(2); var _util = __w_pdfjs_require__(2);
class AnnotationStorage { class AnnotationStorage {
@ -4092,18 +4095,6 @@ class AnnotationStorage {
return obj !== undefined ? obj : defaultValue; return obj !== undefined ? obj : defaultValue;
} }
getOrCreateValue(key, defaultValue) {
(0, _display_utils.deprecated)("Use getValue instead.");
if (this._storage.has(key)) {
return this._storage.get(key);
}
this._storage.set(key, defaultValue);
return defaultValue;
}
setValue(key, value) { setValue(key, value) {
const obj = this._storage.get(key); const obj = this._storage.get(key);
@ -10874,6 +10865,25 @@ const renderTextLayer = function renderTextLayerClosure() {
_processItems(items, styleCache) { _processItems(items, styleCache) {
for (let i = 0, len = items.length; i < len; i++) { for (let i = 0, len = items.length; i < len; i++) {
if (items[i].str === undefined) {
if (items[i].type === "beginMarkedContentProps" || items[i].type === "beginMarkedContent") {
const parent = this._container;
this._container = document.createElement("span");
this._container.classList.add("markedContent");
if (items[i].id !== null) {
this._container.setAttribute("id", `${items[i].id}`);
}
parent.appendChild(this._container);
} else if (items[i].type === "endMarkedContent") {
this._container = this._container.parentNode;
}
continue;
}
this._textContentItemsStr.push(items[i].str); this._textContentItemsStr.push(items[i].str);
appendText(this, items[i], styleCache, this._layoutTextCtx); appendText(this, items[i], styleCache, this._layoutTextCtx);
@ -11454,8 +11464,8 @@ var _svg = __w_pdfjs_require__(21);
var _xfa_layer = __w_pdfjs_require__(22); var _xfa_layer = __w_pdfjs_require__(22);
const pdfjsVersion = '2.8.320'; const pdfjsVersion = '2.9.44';
const pdfjsBuild = 'ca7f54682'; const pdfjsBuild = '6cf307000';
; ;
})(); })();

Просмотреть файл

@ -4768,8 +4768,8 @@ Object.defineProperty(exports, "initSandbox", ({
var _initialization = __w_pdfjs_require__(1); var _initialization = __w_pdfjs_require__(1);
const pdfjsVersion = '2.8.320'; const pdfjsVersion = '2.9.44';
const pdfjsBuild = 'ca7f54682'; const pdfjsBuild = '6cf307000';
})(); })();
/******/ return __webpack_exports__; /******/ return __webpack_exports__;

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -24,7 +24,7 @@
line-height: 1; line-height: 1;
} }
.textLayer > span { .textLayer span {
color: transparent; color: transparent;
position: absolute; position: absolute;
white-space: pre; white-space: pre;
@ -269,20 +269,6 @@
cursor: pointer; cursor: pointer;
} }
*/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
.xfaLayer { .xfaLayer {
position: absolute; position: absolute;
@ -301,6 +287,7 @@
text-decoration: inherit; text-decoration: inherit;
vertical-align: inherit; vertical-align: inherit;
box-sizing: border-box; box-sizing: border-box;
background: transparent;
} }
.xfaFont { .xfaFont {
@ -315,19 +302,23 @@
} }
.xfaDraw { .xfaDraw {
z-index: 200; z-index: 100;
} }
.xfaExclgroup { .xfaExclgroup {
z-index: 300; z-index: 200;
} }
.xfaField { .xfaField {
z-index: 300; z-index: 300;
} }
.xfaRich {
z-index: 300;
}
.xfaSubform { .xfaSubform {
z-index: 100; z-index: 200;
} }
.xfaLabel { .xfaLabel {
@ -348,6 +339,7 @@
height: 100%; height: 100%;
flex: 1 1 auto; flex: 1 1 auto;
border: none; border: none;
resize: none;
} }
.xfaLabel > input[type="checkbox"] { .xfaLabel > input[type="checkbox"] {
@ -394,6 +386,16 @@
background: Highlight; background: Highlight;
} }
.xfaRich {
white-space: pre-wrap;
}
.xfaImage,
.xfaRich {
width: 100%;
height: 100%;
}
.xfaLrTb, .xfaLrTb,
.xfaRlTb, .xfaRlTb,
.xfaTb, .xfaTb,
@ -405,6 +407,10 @@
position: relative; position: relative;
} }
.xfaArea {
position: relative;
}
.xfaValignMiddle { .xfaValignMiddle {
display: flex; display: flex;
align-items: center; align-items: center;
@ -445,6 +451,26 @@
flex: 1; flex: 1;
} }
:root {
--pdfViewer-padding-bottom: none;
--page-margin: 1px auto -8px;
--page-border: 9px solid transparent;
--spreadHorizontalWrapped-margin-LR: -3.5px;
}
@media screen and (forced-colors: active) {
:root {
--pdfViewer-padding-bottom: 9px;
--page-margin: 9px auto 0;
--page-border: none;
--spreadHorizontalWrapped-margin-LR: 4.5px;
}
}
.pdfViewer {
padding-bottom: var(--pdfViewer-padding-bottom);
}
.pdfViewer .canvasWrapper { .pdfViewer .canvasWrapper {
overflow: hidden; overflow: hidden;
} }
@ -453,10 +479,10 @@
direction: ltr; direction: ltr;
width: 816px; width: 816px;
height: 1056px; height: 1056px;
margin: 1px auto -8px; margin: var(--page-margin);
position: relative; position: relative;
overflow: visible; overflow: visible;
border: 9px solid transparent; border: var(--page-border);
background-clip: content-box; background-clip: content-box;
border-image: url(images/shadow.png) 9 9 repeat; border-image: url(images/shadow.png) 9 9 repeat;
background-color: rgba(255, 255, 255, 1); background-color: rgba(255, 255, 255, 1);
@ -508,8 +534,8 @@
.spread .page, .spread .page,
.pdfViewer.scrollHorizontal .page, .pdfViewer.scrollHorizontal .page,
.pdfViewer.scrollWrapped .page { .pdfViewer.scrollWrapped .page {
margin-left: -3.5px; margin-left: var(--spreadHorizontalWrapped-margin-LR);
margin-right: -3.5px; margin-right: var(--spreadHorizontalWrapped-margin-LR);
} }
.pdfViewer.removePageBorders .spread .page, .pdfViewer.removePageBorders .spread .page,
@ -570,19 +596,21 @@
--main-color: rgba(12, 12, 13, 1); --main-color: rgba(12, 12, 13, 1);
--body-bg-color: rgba(237, 237, 240, 1); --body-bg-color: rgba(237, 237, 240, 1);
--errorWrapper-bg-color: rgba(255, 74, 74, 1); --errorWrapper-bg-color: rgba(255, 110, 110, 1);
--progressBar-color: rgba(10, 132, 255, 1); --progressBar-color: rgba(10, 132, 255, 1);
--progressBar-indeterminate-bg-color: rgba(221, 221, 222, 1); --progressBar-indeterminate-bg-color: rgba(221, 221, 222, 1);
--progressBar-indeterminate-blend-color: rgba(116, 177, 239, 1); --progressBar-indeterminate-blend-color: rgba(116, 177, 239, 1);
--scrollbar-color: auto; --scrollbar-color: auto;
--scrollbar-bg-color: auto; --scrollbar-bg-color: auto;
--toolbar-icon-bg-color: rgba(0, 0, 0, 1); --toolbar-icon-bg-color: rgba(0, 0, 0, 1);
--toolbar-icon-hover-bg-color: rgba(0, 0, 0, 1);
--sidebar-narrow-bg-color: rgba(237, 237, 240, 0.9); --sidebar-narrow-bg-color: rgba(237, 237, 240, 0.9);
--sidebar-toolbar-bg-color: rgba(245, 246, 247, 1); --sidebar-toolbar-bg-color: rgba(245, 246, 247, 1);
--toolbar-bg-color: rgba(249, 249, 250, 1); --toolbar-bg-color: rgba(249, 249, 250, 1);
--toolbar-border-color: rgba(204, 204, 204, 1); --toolbar-border-color: rgba(204, 204, 204, 1);
--button-hover-color: rgba(221, 222, 223, 1); --button-hover-color: rgba(221, 222, 223, 1);
--toggled-btn-color: rgba(0, 0, 0, 1);
--toggled-btn-bg-color: rgba(0, 0, 0, 0.3); --toggled-btn-bg-color: rgba(0, 0, 0, 0.3);
--toggled-hover-active-btn-color: rgba(0, 0, 0, 0.4); --toggled-hover-active-btn-color: rgba(0, 0, 0, 0.4);
--dropdown-btn-bg-color: rgba(215, 215, 219, 1); --dropdown-btn-bg-color: rgba(215, 215, 219, 1);
@ -598,10 +626,12 @@
--sidebaritem-bg-color: rgba(0, 0, 0, 0.15); --sidebaritem-bg-color: rgba(0, 0, 0, 0.15);
--doorhanger-bg-color: rgba(255, 255, 255, 1); --doorhanger-bg-color: rgba(255, 255, 255, 1);
--doorhanger-border-color: rgba(12, 12, 13, 0.2); --doorhanger-border-color: rgba(12, 12, 13, 0.2);
--doorhanger-hover-color: rgba(237, 237, 237, 1); --doorhanger-hover-color: rgba(12, 12, 13, 1);
--doorhanger-hover-bg-color: rgba(237, 237, 237, 1);
--doorhanger-separator-color: rgba(222, 222, 222, 1); --doorhanger-separator-color: rgba(222, 222, 222, 1);
--overlay-button-border: 0 none;
--overlay-button-bg-color: rgba(12, 12, 13, 0.1); --overlay-button-bg-color: rgba(12, 12, 13, 0.1);
--overlay-button-hover-color: rgba(12, 12, 13, 0.3); --overlay-button-hover-bg-color: rgba(12, 12, 13, 0.3);
--loading-icon: url(images/loading.svg); --loading-icon: url(images/loading.svg);
--treeitem-expanded-icon: url(images/treeitem-expanded.svg); --treeitem-expanded-icon: url(images/treeitem-expanded.svg);
@ -645,19 +675,21 @@
:root { :root {
--main-color: rgba(249, 249, 250, 1); --main-color: rgba(249, 249, 250, 1);
--body-bg-color: rgba(42, 42, 46, 1); --body-bg-color: rgba(42, 42, 46, 1);
--errorWrapper-bg-color: rgba(199, 17, 17, 1); --errorWrapper-bg-color: rgba(169, 14, 14, 1);
--progressBar-color: rgba(0, 96, 223, 1); --progressBar-color: rgba(0, 96, 223, 1);
--progressBar-indeterminate-bg-color: rgba(40, 40, 43, 1); --progressBar-indeterminate-bg-color: rgba(40, 40, 43, 1);
--progressBar-indeterminate-blend-color: rgba(20, 68, 133, 1); --progressBar-indeterminate-blend-color: rgba(20, 68, 133, 1);
--scrollbar-color: rgba(121, 121, 123, 1); --scrollbar-color: rgba(121, 121, 123, 1);
--scrollbar-bg-color: rgba(35, 35, 39, 1); --scrollbar-bg-color: rgba(35, 35, 39, 1);
--toolbar-icon-bg-color: rgba(255, 255, 255, 1); --toolbar-icon-bg-color: rgba(255, 255, 255, 1);
--toolbar-icon-hover-bg-color: rgba(255, 255, 255, 1);
--sidebar-narrow-bg-color: rgba(42, 42, 46, 0.9); --sidebar-narrow-bg-color: rgba(42, 42, 46, 0.9);
--sidebar-toolbar-bg-color: rgba(50, 50, 52, 1); --sidebar-toolbar-bg-color: rgba(50, 50, 52, 1);
--toolbar-bg-color: rgba(56, 56, 61, 1); --toolbar-bg-color: rgba(56, 56, 61, 1);
--toolbar-border-color: rgba(12, 12, 13, 1); --toolbar-border-color: rgba(12, 12, 13, 1);
--button-hover-color: rgba(102, 102, 103, 1); --button-hover-color: rgba(102, 102, 103, 1);
--toggled-btn-color: rgba(255, 255, 255, 1);
--toggled-btn-bg-color: rgba(0, 0, 0, 0.3); --toggled-btn-bg-color: rgba(0, 0, 0, 0.3);
--toggled-hover-active-btn-color: rgba(0, 0, 0, 0.4); --toggled-hover-active-btn-color: rgba(0, 0, 0, 0.4);
--dropdown-btn-bg-color: rgba(74, 74, 79, 1); --dropdown-btn-bg-color: rgba(74, 74, 79, 1);
@ -673,10 +705,11 @@
--sidebaritem-bg-color: rgba(255, 255, 255, 0.15); --sidebaritem-bg-color: rgba(255, 255, 255, 0.15);
--doorhanger-bg-color: rgba(74, 74, 79, 1); --doorhanger-bg-color: rgba(74, 74, 79, 1);
--doorhanger-border-color: rgba(39, 39, 43, 1); --doorhanger-border-color: rgba(39, 39, 43, 1);
--doorhanger-hover-color: rgba(93, 94, 98, 1); --doorhanger-hover-color: rgba(249, 249, 250, 1);
--doorhanger-hover-bg-color: rgba(93, 94, 98, 1);
--doorhanger-separator-color: rgba(92, 92, 97, 1); --doorhanger-separator-color: rgba(92, 92, 97, 1);
--overlay-button-bg-color: rgba(92, 92, 97, 1); --overlay-button-bg-color: rgba(92, 92, 97, 1);
--overlay-button-hover-color: rgba(115, 115, 115, 1); --overlay-button-hover-bg-color: rgba(115, 115, 115, 1);
/* This image is used in <input> elements, which unfortunately means that /* This image is used in <input> elements, which unfortunately means that
* the `mask-image` approach used with all of the other images doesn't work * the `mask-image` approach used with all of the other images doesn't work
@ -685,6 +718,26 @@
} }
} }
@media screen and (forced-colors: active) {
:root {
--main-color: ButtonText;
--button-hover-color: Highlight;
--doorhanger-hover-bg-color: Highlight;
--toolbar-icon-opacity: 1;
--toolbar-icon-bg-color: ButtonText;
--toolbar-icon-hover-bg-color: ButtonFace;
--toggled-btn-color: HighlightText;
--toggled-btn-bg-color: LinkText;
--doorhanger-hover-color: ButtonFace;
--doorhanger-border-color-whcm: 1px solid ButtonText;
--doorhanger-triangle-opacity-whcm: 0;
--overlay-button-border: 1px solid Highlight;
--overlay-button-hover-bg-color: Highlight;
--overlay-button-hover-color: ButtonFace;
--field-border-color: ButtonText;
}
}
* { * {
padding: 0; padding: 0;
margin: 0; margin: 0;
@ -719,7 +772,7 @@ select {
display: none !important; display: none !important;
} }
.pdfViewer.enablePermissions .textLayer > span { .pdfViewer.enablePermissions .textLayer span {
user-select: none !important; user-select: none !important;
cursor: not-allowed; cursor: not-allowed;
} }
@ -739,12 +792,12 @@ select {
display: none; display: none;
} }
.pdfPresentationMode:fullscreen .textLayer > span { .pdfPresentationMode:fullscreen .textLayer span {
cursor: none; cursor: none;
} }
.pdfPresentationMode.pdfPresentationModeControls > *, .pdfPresentationMode.pdfPresentationModeControls > *,
.pdfPresentationMode.pdfPresentationModeControls .textLayer > span { .pdfPresentationMode.pdfPresentationModeControls .textLayer span {
cursor: default; cursor: default;
} }
@ -768,10 +821,12 @@ select {
html[dir="ltr"] #sidebarContainer { html[dir="ltr"] #sidebarContainer {
transition-property: left; transition-property: left;
left: calc(0px - var(--sidebar-width)); left: calc(0px - var(--sidebar-width));
border-right: var(--doorhanger-border-color-whcm);
} }
html[dir="rtl"] #sidebarContainer { html[dir="rtl"] #sidebarContainer {
transition-property: right; transition-property: right;
right: calc(0px - var(--sidebar-width)); right: calc(0px - var(--sidebar-width));
border-left: var(--doorhanger-border-color-whcm);
} }
#outerContainer.sidebarResizing #sidebarContainer { #outerContainer.sidebarResizing #sidebarContainer {
@ -1077,6 +1132,7 @@ html[dir="rtl"] .findbar .splitToolbarButton > .findNext {
.findbar label:hover, .findbar label:hover,
.findbar input:focus + label { .findbar input:focus + label {
color: var(--toggled-btn-color);
background-color: var(--button-hover-color); background-color: var(--button-hover-color);
} }
@ -1091,6 +1147,7 @@ html[dir="rtl"] #findInput {
.findbar .toolbarField[type="checkbox"]:checked + .toolbarLabel { .findbar .toolbarField[type="checkbox"]:checked + .toolbarLabel {
background-color: var(--toggled-btn-bg-color) !important; background-color: var(--toggled-btn-bg-color) !important;
color: var(--toggled-btn-color);
} }
#findInput { #findInput {
@ -1141,6 +1198,7 @@ html[dir="rtl"] .secondaryToolbar {
border-radius: 2px; border-radius: 2px;
box-shadow: 0 1px 5px var(--doorhanger-border-color), box-shadow: 0 1px 5px var(--doorhanger-border-color),
0 0 0 1px var(--doorhanger-border-color); 0 0 0 1px var(--doorhanger-border-color);
border: var(--doorhanger-border-color-whcm);
} }
.doorHanger:after, .doorHanger:after,
.doorHanger:before, .doorHanger:before,
@ -1153,6 +1211,7 @@ html[dir="rtl"] .secondaryToolbar {
width: 0; width: 0;
position: absolute; position: absolute;
pointer-events: none; pointer-events: none;
opacity: var(--doorhanger-triangle-opacity-whcm);
} }
.doorHanger:after, .doorHanger:after,
.doorHangerRight:after { .doorHangerRight:after {
@ -1198,7 +1257,7 @@ html[dir="ltr"] .doorHangerRight:before {
background-color: rgba(217, 217, 217, 1); background-color: rgba(217, 217, 217, 1);
color: rgba(82, 82, 82, 1); color: rgba(82, 82, 82, 1);
text-align: center; text-align: center;
padding: 3px 4px; padding: 4px 5px;
margin: 5px; margin: 5px;
} }
@ -1265,13 +1324,15 @@ html[dir="rtl"] .splitToolbarButton > .toolbarButton {
width: 28px; width: 28px;
height: 28px; height: 28px;
} }
.overlayButton {
background-color: var(--overlay-button-bg-color);
}
.overlayButton:hover, .overlayButton:hover,
.overlayButton:focus { .overlayButton:focus {
background-color: var(--overlay-button-hover-color); background-color: var(--overlay-button-hover-bg-color);
}
.overlayButton:hover > span,
.overlayButton:focus > span {
color: var(--overlay-button-hover-color);
} }
.toolbarButton > span { .toolbarButton > span {
@ -1364,13 +1425,23 @@ html[dir="rtl"] #toolbarViewerLeft > .toolbarButton:first-child {
} }
.secondaryToolbarButton:hover, .secondaryToolbarButton:hover,
.secondaryToolbarButton:focus { .secondaryToolbarButton:focus {
background-color: var(--doorhanger-hover-color); background-color: var(--doorhanger-hover-bg-color);
color: var(--doorhanger-hover-color);
} }
.toolbarButton.toggled, .toolbarButton.toggled,
.splitToolbarButton.toggled > .toolbarButton.toggled, .splitToolbarButton.toggled > .toolbarButton.toggled,
.secondaryToolbarButton.toggled { .secondaryToolbarButton.toggled {
background-color: var(--toggled-btn-bg-color); background-color: var(--toggled-btn-bg-color);
color: var(--toggled-btn-color);
}
.secondaryToolbarButton.toggled::before {
background-color: var(--toggled-btn-color);
}
.toolbarButton.toggled::before {
background-color: var(--toggled-btn-color);
} }
.toolbarButton.toggled:hover:active, .toolbarButton.toggled:hover:active,
@ -1415,16 +1486,15 @@ html[dir="ltr"] .dropdownToolbarButton > select {
html[dir="rtl"] .dropdownToolbarButton > select { html[dir="rtl"] .dropdownToolbarButton > select {
padding-right: 4px; padding-right: 4px;
} }
.dropdownToolbarButton > select:hover { .dropdownToolbarButton > select:hover,
background-color: var(--button-hover-color);
}
.dropdownToolbarButton > select:focus { .dropdownToolbarButton > select:focus {
background-color: var(--button-hover-color); background-color: var(--button-hover-color);
color: var(--toggled-btn-color);
} }
.dropdownToolbarButton > select > option { .dropdownToolbarButton > select > option {
background: var(--doorhanger-bg-color); background: var(--doorhanger-bg-color);
color: var(--main-color);
} }
#customScaleOption { #customScaleOption {
@ -1457,12 +1527,25 @@ html[dir="rtl"] .dropdownToolbarButton > select {
mask-size: cover; mask-size: cover;
} }
.dropdownToolbarButton:hover::after,
.dropdownToolbarButton:focus::after,
.dropdownToolbarButton:active::after {
background-color: var(--toolbar-icon-hover-bg-color);
}
.toolbarButton::before { .toolbarButton::before {
opacity: var(--toolbar-icon-opacity); opacity: var(--toolbar-icon-opacity);
top: 6px; top: 6px;
left: 6px; left: 6px;
} }
.toolbarButton:hover::before,
.toolbarButton:focus::before,
.secondaryToolbarButton:hover::before,
.secondaryToolbarButton:focus::before {
background-color: var(--toolbar-icon-hover-bg-color);
}
.secondaryToolbarButton::before { .secondaryToolbarButton::before {
opacity: var(--doorhanger-icon-opacity); opacity: var(--doorhanger-icon-opacity);
top: 5px; top: 5px;
@ -1746,9 +1829,8 @@ html[dir="rtl"] .toolbarField[type="checkbox"] {
.toolbarLabel { .toolbarLabel {
min-width: 16px; min-width: 16px;
padding: 6px; padding: 7px;
margin: 2px; margin: 2px;
border: 1px solid rgba(0, 0, 0, 0);
border-radius: 2px; border-radius: 2px;
color: var(--main-color); color: var(--main-color);
font-size: 12px; font-size: 12px;
@ -1759,10 +1841,10 @@ html[dir="rtl"] .toolbarField[type="checkbox"] {
} }
html[dir="ltr"] #numPages.toolbarLabel { html[dir="ltr"] #numPages.toolbarLabel {
padding-left: 2px; padding-left: 3px;
} }
html[dir="rtl"] #numPages.toolbarLabel { html[dir="rtl"] #numPages.toolbarLabel {
padding-right: 2px; padding-right: 3px;
} }
#thumbnailView { #thumbnailView {
@ -1977,6 +2059,9 @@ html[dir="rtl"] .treeItemToggler::before {
width: auto; width: auto;
margin: 3px 4px 2px !important; margin: 3px 4px 2px !important;
padding: 2px 11px; padding: 2px 11px;
color: var(--main-color);
background-color: var(--overlay-button-bg-color);
border: var(--overlay-button-border) !important;
} }
#overlayContainer { #overlayContainer {
@ -2145,19 +2230,19 @@ html[dir="rtl"] #documentPropertiesOverlay .row > * {
mix-blend-mode: screen; mix-blend-mode: screen;
} }
#viewer.textLayer-visible .textLayer > span { #viewer.textLayer-visible .textLayer span {
background-color: rgba(255, 255, 0, 0.1); background-color: rgba(255, 255, 0, 0.1);
color: rgba(0, 0, 0, 1); color: rgba(0, 0, 0, 1);
border: solid 1px rgba(255, 0, 0, 0.5); border: solid 1px rgba(255, 0, 0, 0.5);
box-sizing: border-box; box-sizing: border-box;
} }
#viewer.textLayer-hover .textLayer > span:hover { #viewer.textLayer-hover .textLayer span:hover {
background-color: rgba(255, 255, 255, 1); background-color: rgba(255, 255, 255, 1);
color: rgba(0, 0, 0, 1); color: rgba(0, 0, 0, 1);
} }
#viewer.textLayer-shadow .textLayer > span { #viewer.textLayer-shadow .textLayer span {
background-color: rgba(255, 255, 255, 0.6); background-color: rgba(255, 255, 255, 0.6);
color: rgba(0, 0, 0, 1); color: rgba(0, 0, 0, 1);
} }

Просмотреть файл

@ -351,13 +351,13 @@ var _pdf_thumbnail_viewer = __webpack_require__(25);
var _pdf_viewer = __webpack_require__(27); var _pdf_viewer = __webpack_require__(27);
var _secondary_toolbar = __webpack_require__(34); var _secondary_toolbar = __webpack_require__(35);
var _toolbar = __webpack_require__(36); var _toolbar = __webpack_require__(37);
var _viewer_compatibility = __webpack_require__(2); var _viewer_compatibility = __webpack_require__(2);
var _view_history = __webpack_require__(37); var _view_history = __webpack_require__(38);
const DEFAULT_SCALE_DELTA = 1.1; const DEFAULT_SCALE_DELTA = 1.1;
const DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000; const DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
@ -433,7 +433,7 @@ exports.DefaultExternalServices = DefaultExternalServices;
const PDFViewerApplication = { const PDFViewerApplication = {
initialBookmark: document.location.hash.substring(1), initialBookmark: document.location.hash.substring(1),
_initializedCapability: (0, _pdfjsLib.createPromiseCapability)(), _initializedCapability: (0, _pdfjsLib.createPromiseCapability)(),
fellback: false, _fellback: false,
appConfig: null, appConfig: null,
pdfDocument: null, pdfDocument: null,
pdfLoadingTask: null, pdfLoadingTask: null,
@ -640,7 +640,7 @@ const PDFViewerApplication = {
this.eventBus = eventBus; this.eventBus = eventBus;
this.overlayManager = new _overlay_manager.OverlayManager(); this.overlayManager = new _overlay_manager.OverlayManager();
const pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue(); const pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
pdfRenderingQueue.onIdle = this.cleanup.bind(this); pdfRenderingQueue.onIdle = this._cleanup.bind(this);
this.pdfRenderingQueue = pdfRenderingQueue; this.pdfRenderingQueue = pdfRenderingQueue;
const pdfLinkService = new _pdf_link_service.PDFLinkService({ const pdfLinkService = new _pdf_link_service.PDFLinkService({
eventBus, eventBus,
@ -919,7 +919,7 @@ const PDFViewerApplication = {
this._unblockDocumentLoadEvent(); this._unblockDocumentLoadEvent();
if (!this.pdfLoadingTask) { if (!this.pdfLoadingTask) {
return undefined; return;
} }
const promises = []; const promises = [];
@ -935,6 +935,7 @@ const PDFViewerApplication = {
} }
webViewerResetPermissions(); webViewerResetPermissions();
this._fellback = false;
this.store = null; this.store = null;
this.isInitialViewSet = false; this.isInitialViewSet = false;
this.downloadComplete = false; this.downloadComplete = false;
@ -971,7 +972,6 @@ const PDFViewerApplication = {
} }
await Promise.all(promises); await Promise.all(promises);
return undefined;
}, },
async open(file, args) { async open(file, args) {
@ -1059,28 +1059,31 @@ const PDFViewerApplication = {
}); });
}, },
download({ _ensureDownloadComplete() {
sourceEventType = "download" if (this.pdfDocument && this.downloadComplete) {
} = {}) {
function downloadByUrl() {
downloadManager.downloadUrl(url, filename);
}
const downloadManager = this.downloadManager,
url = this.baseUrl,
filename = this._docFilename;
if (!this.pdfDocument || !this.downloadComplete) {
downloadByUrl();
return; return;
} }
this.pdfDocument.getData().then(function (data) { throw new Error("PDF document not downloaded.");
},
async download({
sourceEventType = "download"
} = {}) {
const url = this.baseUrl,
filename = this._docFilename;
try {
this._ensureDownloadComplete();
const data = await this.pdfDocument.getData();
const blob = new Blob([data], { const blob = new Blob([data], {
type: "application/pdf" type: "application/pdf"
}); });
downloadManager.download(blob, url, filename, sourceEventType); await this.downloadManager.download(blob, url, filename, sourceEventType);
}).catch(downloadByUrl); } catch (reason) {
await this.downloadManager.downloadUrl(url, filename);
}
}, },
async save({ async save({
@ -1090,32 +1093,27 @@ const PDFViewerApplication = {
return; return;
} }
const downloadManager = this.downloadManager,
url = this.baseUrl,
filename = this._docFilename;
if (!this.pdfDocument || !this.downloadComplete) {
this.download({
sourceEventType
});
return;
}
this._saveInProgress = true; this._saveInProgress = true;
await this.pdfScriptingManager.dispatchWillSave(); await this.pdfScriptingManager.dispatchWillSave();
this.pdfDocument.saveDocument(this.pdfDocument.annotationStorage).then(data => { const url = this.baseUrl,
filename = this._docFilename;
try {
this._ensureDownloadComplete();
const data = await this.pdfDocument.saveDocument();
const blob = new Blob([data], { const blob = new Blob([data], {
type: "application/pdf" type: "application/pdf"
}); });
downloadManager.download(blob, url, filename, sourceEventType); await this.downloadManager.download(blob, url, filename, sourceEventType);
}).catch(() => { } catch (reason) {
this.download({ await this.download({
sourceEventType sourceEventType
}); });
}).finally(async () => { } finally {
await this.pdfScriptingManager.dispatchDidSave(); await this.pdfScriptingManager.dispatchDidSave();
this._saveInProgress = false; this._saveInProgress = false;
}); }
}, },
downloadOrSave(options) { downloadOrSave(options) {
@ -1152,11 +1150,11 @@ const PDFViewerApplication = {
return; return;
} }
if (this.fellback) { if (this._fellback) {
return; return;
} }
this.fellback = true; this._fellback = true;
this.externalServices.fallback({ this.externalServices.fallback({
featureId, featureId,
url: this.baseUrl url: this.baseUrl
@ -1379,17 +1377,29 @@ const PDFViewerApplication = {
}); });
onePageRendered.then(() => { onePageRendered.then(() => {
pdfDocument.getOutline().then(outline => { pdfDocument.getOutline().then(outline => {
if (pdfDocument !== this.pdfDocument) {
return;
}
this.pdfOutlineViewer.render({ this.pdfOutlineViewer.render({
outline, outline,
pdfDocument pdfDocument
}); });
}); });
pdfDocument.getAttachments().then(attachments => { pdfDocument.getAttachments().then(attachments => {
if (pdfDocument !== this.pdfDocument) {
return;
}
this.pdfAttachmentViewer.render({ this.pdfAttachmentViewer.render({
attachments attachments
}); });
}); });
pdfViewer.optionalContentConfigPromise.then(optionalContentConfig => { pdfViewer.optionalContentConfigPromise.then(optionalContentConfig => {
if (pdfDocument !== this.pdfDocument) {
return;
}
this.pdfLayerViewer.render({ this.pdfLayerViewer.render({
optionalContentConfig, optionalContentConfig,
pdfDocument pdfDocument
@ -1544,6 +1554,11 @@ const PDFViewerApplication = {
this._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms); this._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
} }
if (info.IsSignaturesPresent) {
console.warn("Warning: Digital signatures validation is not supported");
this.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.signatures);
}
let versionId = "other"; let versionId = "other";
if (KNOWN_VERSIONS.includes(info.PDFFormatVersion)) { if (KNOWN_VERSIONS.includes(info.PDFFormatVersion)) {
@ -1676,11 +1691,11 @@ const PDFViewerApplication = {
annotationStorage annotationStorage
} = pdfDocument; } = pdfDocument;
annotationStorage.onSetModified = function () { annotationStorage.onSetModified = () => {
window.addEventListener("beforeunload", beforeUnload); window.addEventListener("beforeunload", beforeUnload);
}; };
annotationStorage.onResetModified = function () { annotationStorage.onResetModified = () => {
window.removeEventListener("beforeunload", beforeUnload); window.removeEventListener("beforeunload", beforeUnload);
}; };
}, },
@ -1729,17 +1744,14 @@ const PDFViewerApplication = {
} }
}, },
cleanup() { _cleanup() {
if (!this.pdfDocument) { if (!this.pdfDocument) {
return; return;
} }
this.pdfViewer.cleanup(); this.pdfViewer.cleanup();
this.pdfThumbnailViewer.cleanup(); this.pdfThumbnailViewer.cleanup();
this.pdfDocument.cleanup(this.pdfViewer.renderer === _ui_utils.RendererType.SVG);
if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
this.pdfDocument.cleanup();
}
}, },
forceRendering() { forceRendering() {
@ -5339,7 +5351,7 @@ class PDFFindController {
this._pageDiffs = []; this._pageDiffs = [];
this._matchesCountTotal = 0; this._matchesCountTotal = 0;
this._pagesToSearch = null; this._pagesToSearch = null;
this._pendingFindMatches = Object.create(null); this._pendingFindMatches = new Set();
this._resumePageIdx = null; this._resumePageIdx = null;
this._dirtyMatch = false; this._dirtyMatch = false;
clearTimeout(this._findTimeout); clearTimeout(this._findTimeout);
@ -5629,14 +5641,14 @@ class PDFFindController {
this._updateAllPages(); this._updateAllPages();
for (let i = 0; i < numPages; i++) { for (let i = 0; i < numPages; i++) {
if (this._pendingFindMatches[i] === true) { if (this._pendingFindMatches.has(i)) {
continue; continue;
} }
this._pendingFindMatches[i] = true; this._pendingFindMatches.add(i);
this._extractTextPromises[i].then(pageIdx => { this._extractTextPromises[i].then(pageIdx => {
delete this._pendingFindMatches[pageIdx]; this._pendingFindMatches.delete(pageIdx);
this._calculateMatch(pageIdx); this._calculateMatch(pageIdx);
}); });
@ -6790,11 +6802,6 @@ class PDFLinkService {
this.pdfViewer.pagesRotation = value; this.pdfViewer.pagesRotation = value;
} }
navigateTo(dest) {
console.error("Deprecated method: `navigateTo`, use `goToDestination` instead.");
this.goToDestination(dest);
}
_goToDestinationHelper(rawDest, namedDest = null, explicitDest) { _goToDestinationHelper(rawDest, namedDest = null, explicitDest) {
const destRef = explicitDest[0]; const destRef = explicitDest[0];
let pageNumber; let pageNumber;
@ -7223,6 +7230,10 @@ class PDFOutlineViewer extends _base_tree_viewer.BaseTreeViewer {
this.eventBus._on("pagesloaded", evt => { this.eventBus._on("pagesloaded", evt => {
this._isPagesLoaded = !!evt.pagesCount; this._isPagesLoaded = !!evt.pagesCount;
if (this._currentOutlineItemCapability && !this._currentOutlineItemCapability.settled) {
this._currentOutlineItemCapability.resolve(this._isPagesLoaded);
}
}); });
this.eventBus._on("sidebarviewchanged", evt => { this.eventBus._on("sidebarviewchanged", evt => {
@ -7236,13 +7247,27 @@ class PDFOutlineViewer extends _base_tree_viewer.BaseTreeViewer {
this._pageNumberToDestHashCapability = null; this._pageNumberToDestHashCapability = null;
this._currentPageNumber = 1; this._currentPageNumber = 1;
this._isPagesLoaded = false; this._isPagesLoaded = false;
if (this._currentOutlineItemCapability && !this._currentOutlineItemCapability.settled) {
this._currentOutlineItemCapability.resolve(false);
}
this._currentOutlineItemCapability = null;
} }
_dispatchEvent(outlineCount) { _dispatchEvent(outlineCount) {
this._currentOutlineItemCapability = (0, _pdfjsLib.createPromiseCapability)();
if (outlineCount === 0 || this._pdfDocument?.loadingParams.disableAutoFetch) {
this._currentOutlineItemCapability.resolve(false);
} else if (this._isPagesLoaded) {
this._currentOutlineItemCapability.resolve(true);
}
this.eventBus.dispatch("outlineloaded", { this.eventBus.dispatch("outlineloaded", {
source: this, source: this,
outlineCount, outlineCount,
enableCurrentOutlineItemButton: outlineCount > 0 && !this._pdfDocument?.loadingParams.disableAutoFetch currentOutlineItemPromise: this._currentOutlineItemCapability.promise
}); });
} }
@ -8635,12 +8660,13 @@ class PDFSidebar {
this.eventBus._on("outlineloaded", evt => { this.eventBus._on("outlineloaded", evt => {
onTreeLoaded(evt.outlineCount, this.outlineButton, _ui_utils.SidebarView.OUTLINE); onTreeLoaded(evt.outlineCount, this.outlineButton, _ui_utils.SidebarView.OUTLINE);
evt.currentOutlineItemPromise.then(enabled => {
if (!this.isInitialViewSet) {
return;
}
if (evt.enableCurrentOutlineItemButton) { this._currentOutlineItemButton.disabled = !enabled;
this.pdfViewer.pagesPromise.then(() => { });
this._currentOutlineItemButton.disabled = !this.isInitialViewSet;
});
}
}); });
this.eventBus._on("attachmentsloaded", evt => { this.eventBus._on("attachmentsloaded", evt => {
@ -9091,6 +9117,7 @@ var _pdfjsLib = __webpack_require__(5);
var _pdf_rendering_queue = __webpack_require__(8); var _pdf_rendering_queue = __webpack_require__(8);
const DRAW_UPSCALE_FACTOR = 2;
const MAX_NUM_SCALING_STEPS = 3; const MAX_NUM_SCALING_STEPS = 3;
const THUMBNAIL_CANVAS_BORDER_WIDTH = 1; const THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
const THUMBNAIL_WIDTH = 98; const THUMBNAIL_WIDTH = 98;
@ -9116,7 +9143,7 @@ const TempImageFactory = function TempImageFactoryClosure() {
ctx.fillStyle = "rgb(255, 255, 255)"; ctx.fillStyle = "rgb(255, 255, 255)";
ctx.fillRect(0, 0, width, height); ctx.fillRect(0, 0, width, height);
ctx.restore(); ctx.restore();
return tempCanvas; return [tempCanvas, tempCanvas.getContext("2d")];
}, },
destroyCanvas() { destroyCanvas() {
@ -9166,12 +9193,12 @@ class PDFThumbnailView {
}; };
this.disableCanvasToImageConversion = disableCanvasToImageConversion; this.disableCanvasToImageConversion = disableCanvasToImageConversion;
this.pageWidth = this.viewport.width; const pageWidth = this.viewport.width,
this.pageHeight = this.viewport.height; pageHeight = this.viewport.height,
this.pageRatio = this.pageWidth / this.pageHeight; pageRatio = pageWidth / pageHeight;
this.canvasWidth = THUMBNAIL_WIDTH; this.canvasWidth = THUMBNAIL_WIDTH;
this.canvasHeight = this.canvasWidth / this.pageRatio | 0; this.canvasHeight = this.canvasWidth / pageRatio | 0;
this.scale = this.canvasWidth / this.pageWidth; this.scale = this.canvasWidth / pageWidth;
this.l10n = l10n; this.l10n = l10n;
const anchor = document.createElement("a"); const anchor = document.createElement("a");
anchor.href = linkService.getAnchorUrl("#page=" + id); anchor.href = linkService.getAnchorUrl("#page=" + id);
@ -9215,19 +9242,14 @@ class PDFThumbnailView {
reset() { reset() {
this.cancelRendering(); this.cancelRendering();
this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL; this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
this.pageWidth = this.viewport.width; const pageWidth = this.viewport.width,
this.pageHeight = this.viewport.height; pageHeight = this.viewport.height,
this.pageRatio = this.pageWidth / this.pageHeight; pageRatio = pageWidth / pageHeight;
this.canvasHeight = this.canvasWidth / this.pageRatio | 0; this.canvasHeight = this.canvasWidth / pageRatio | 0;
this.scale = this.canvasWidth / this.pageWidth; this.scale = this.canvasWidth / pageWidth;
this.div.removeAttribute("data-loaded"); this.div.removeAttribute("data-loaded");
const ring = this.ring; const ring = this.ring;
const childNodes = ring.childNodes; ring.textContent = "";
for (let i = childNodes.length - 1; i >= 0; i--) {
ring.removeChild(childNodes[i]);
}
const borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH; const borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
ring.style.width = this.canvasWidth + borderAdjustment + "px"; ring.style.width = this.canvasWidth + borderAdjustment + "px";
ring.style.height = this.canvasHeight + borderAdjustment + "px"; ring.style.height = this.canvasHeight + borderAdjustment + "px";
@ -9266,47 +9288,47 @@ class PDFThumbnailView {
this.resume = null; this.resume = null;
} }
_getPageDrawContext() { _getPageDrawContext(upscaleFactor = 1) {
const canvas = document.createElement("canvas"); const canvas = document.createElement("canvas");
this.canvas = canvas;
canvas.mozOpaque = true; canvas.mozOpaque = true;
const ctx = canvas.getContext("2d", { const ctx = canvas.getContext("2d", {
alpha: false alpha: false
}); });
const outputScale = (0, _ui_utils.getOutputScale)(ctx); const outputScale = (0, _ui_utils.getOutputScale)(ctx);
canvas.width = this.canvasWidth * outputScale.sx | 0; canvas.width = upscaleFactor * this.canvasWidth * outputScale.sx | 0;
canvas.height = this.canvasHeight * outputScale.sy | 0; canvas.height = upscaleFactor * this.canvasHeight * outputScale.sy | 0;
canvas.style.width = this.canvasWidth + "px";
canvas.style.height = this.canvasHeight + "px";
const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null; const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
return [ctx, transform]; return {
ctx,
canvas,
transform
};
} }
_convertCanvasToImage() { _convertCanvasToImage(canvas) {
if (!this.canvas) {
return;
}
if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) { if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
return; throw new Error("_convertCanvasToImage: Rendering has not finished.");
} }
const className = "thumbnailImage"; const reducedCanvas = this._reduceImage(canvas);
if (this.disableCanvasToImageConversion) { if (this.disableCanvasToImageConversion) {
this.canvas.className = className; reducedCanvas.className = "thumbnailImage";
this._thumbPageCanvas.then(msg => { this._thumbPageCanvas.then(msg => {
this.canvas.setAttribute("aria-label", msg); reducedCanvas.setAttribute("aria-label", msg);
}); });
reducedCanvas.style.width = this.canvasWidth + "px";
reducedCanvas.style.height = this.canvasHeight + "px";
this.canvas = reducedCanvas;
this.div.setAttribute("data-loaded", true); this.div.setAttribute("data-loaded", true);
this.ring.appendChild(this.canvas); this.ring.appendChild(reducedCanvas);
return; return;
} }
const image = document.createElement("img"); const image = document.createElement("img");
image.className = className; image.className = "thumbnailImage";
this._thumbPageCanvas.then(msg => { this._thumbPageCanvas.then(msg => {
image.setAttribute("aria-label", msg); image.setAttribute("aria-label", msg);
@ -9314,13 +9336,12 @@ class PDFThumbnailView {
image.style.width = this.canvasWidth + "px"; image.style.width = this.canvasWidth + "px";
image.style.height = this.canvasHeight + "px"; image.style.height = this.canvasHeight + "px";
image.src = this.canvas.toDataURL(); image.src = reducedCanvas.toDataURL();
this.image = image; this.image = image;
this.div.setAttribute("data-loaded", true); this.div.setAttribute("data-loaded", true);
this.ring.appendChild(image); this.ring.appendChild(image);
this.canvas.width = 0; reducedCanvas.width = 0;
this.canvas.height = 0; reducedCanvas.height = 0;
delete this.canvas;
} }
draw() { draw() {
@ -9351,17 +9372,21 @@ class PDFThumbnailView {
this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED; this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
this._convertCanvasToImage(); this._convertCanvasToImage(canvas);
if (error) { if (error) {
throw error; throw error;
} }
}; };
const [ctx, transform] = this._getPageDrawContext(); const {
ctx,
canvas,
transform
} = this._getPageDrawContext(DRAW_UPSCALE_FACTOR);
const drawViewport = this.viewport.clone({ const drawViewport = this.viewport.clone({
scale: this.scale scale: DRAW_UPSCALE_FACTOR * this.scale
}); });
const renderContinueCallback = cont => { const renderContinueCallback = cont => {
@ -9388,18 +9413,18 @@ class PDFThumbnailView {
const renderTask = this.renderTask = pdfPage.render(renderContext); const renderTask = this.renderTask = pdfPage.render(renderContext);
renderTask.onContinue = renderContinueCallback; renderTask.onContinue = renderContinueCallback;
const resultPromise = renderTask.promise.then(function () { const resultPromise = renderTask.promise.then(function () {
finishRenderTask(null); return finishRenderTask(null);
}, function (error) { }, function (error) {
finishRenderTask(error); return finishRenderTask(error);
}); });
resultPromise.finally(() => { resultPromise.finally(() => {
canvas.width = 0;
canvas.height = 0;
const pageCached = this.linkService.isPageCached(this.id); const pageCached = this.linkService.isPageCached(this.id);
if (pageCached) { if (!pageCached) {
return; this.pdfPage?.cleanup();
} }
this.pdfPage?.cleanup();
}); });
return resultPromise; return resultPromise;
} }
@ -9413,34 +9438,38 @@ class PDFThumbnailView {
return; return;
} }
const img = pageView.canvas; const {
canvas,
pdfPage
} = pageView;
if (!img) { if (!canvas) {
return; return;
} }
if (!this.pdfPage) { if (!this.pdfPage) {
this.setPdfPage(pageView.pdfPage); this.setPdfPage(pdfPage);
} }
this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED; this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
const [ctx] = this._getPageDrawContext(); this._convertCanvasToImage(canvas);
}
const canvas = ctx.canvas; _reduceImage(img) {
const {
ctx,
canvas
} = this._getPageDrawContext();
if (img.width <= 2 * canvas.width) { if (img.width <= 2 * canvas.width) {
ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height); ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
return canvas;
this._convertCanvasToImage();
return;
} }
let reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS; let reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
let reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS; let reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
const reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight); const [reducedImage, reducedImageCtx] = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
const reducedImageCtx = reducedImage.getContext("2d");
while (reducedWidth > img.width || reducedHeight > img.height) { while (reducedWidth > img.width || reducedHeight > img.height) {
reducedWidth >>= 1; reducedWidth >>= 1;
@ -9456,8 +9485,7 @@ class PDFThumbnailView {
} }
ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height); ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
return canvas;
this._convertCanvasToImage();
} }
get _thumbPageTitle() { get _thumbPageTitle() {
@ -9486,7 +9514,7 @@ class PDFThumbnailView {
this._thumbPageCanvas.then(msg => { this._thumbPageCanvas.then(msg => {
if (this.image) { if (this.image) {
this.image.setAttribute("aria-label", msg); this.image.setAttribute("aria-label", msg);
} else if (this.disableCanvasToImageConversion && this.canvas) { } else if (this.canvas) {
this.canvas.setAttribute("aria-label", msg); this.canvas.setAttribute("aria-label", msg);
} }
}); });
@ -9609,9 +9637,11 @@ var _pdf_page_view = __webpack_require__(31);
var _pdf_link_service = __webpack_require__(19); var _pdf_link_service = __webpack_require__(19);
var _text_layer_builder = __webpack_require__(32); var _struct_tree_layer_builder = __webpack_require__(32);
var _xfa_layer_builder = __webpack_require__(33); var _text_layer_builder = __webpack_require__(33);
var _xfa_layer_builder = __webpack_require__(34);
const DEFAULT_CACHE_SIZE = 10; const DEFAULT_CACHE_SIZE = 10;
@ -9675,7 +9705,7 @@ class BaseViewer {
throw new Error("Cannot initialize BaseViewer."); throw new Error("Cannot initialize BaseViewer.");
} }
const viewerVersion = '2.8.320'; const viewerVersion = '2.9.44';
if (_pdfjsLib.version !== viewerVersion) { if (_pdfjsLib.version !== viewerVersion) {
throw new Error(`The API version "${_pdfjsLib.version}" does not match the Viewer version "${viewerVersion}".`); throw new Error(`The API version "${_pdfjsLib.version}" does not match the Viewer version "${viewerVersion}".`);
@ -10000,14 +10030,14 @@ class BaseViewer {
textLayerMode: this.textLayerMode, textLayerMode: this.textLayerMode,
annotationLayerFactory: this, annotationLayerFactory: this,
xfaLayerFactory, xfaLayerFactory,
structTreeLayerFactory: this,
imageResourcesPath: this.imageResourcesPath, imageResourcesPath: this.imageResourcesPath,
renderInteractiveForms: this.renderInteractiveForms, renderInteractiveForms: this.renderInteractiveForms,
renderer: this.renderer, renderer: this.renderer,
enableWebGL: this.enableWebGL, enableWebGL: this.enableWebGL,
useOnlyCssZoom: this.useOnlyCssZoom, useOnlyCssZoom: this.useOnlyCssZoom,
maxCanvasPixels: this.maxCanvasPixels, maxCanvasPixels: this.maxCanvasPixels,
l10n: this.l10n, l10n: this.l10n
enableScripting: this.enableScripting
}); });
this._pages.push(pageView); this._pages.push(pageView);
@ -10635,7 +10665,7 @@ class BaseViewer {
}); });
} }
createAnnotationLayerBuilder(pageDiv, pdfPage, annotationStorage = null, imageResourcesPath = "", renderInteractiveForms = false, l10n = _l10n_utils.NullL10n, enableScripting = false, hasJSActionsPromise = null, mouseState = null) { createAnnotationLayerBuilder(pageDiv, pdfPage, annotationStorage = null, imageResourcesPath = "", renderInteractiveForms = false, l10n = _l10n_utils.NullL10n, enableScripting = null, hasJSActionsPromise = null, mouseState = null) {
return new _annotation_layer_builder.AnnotationLayerBuilder({ return new _annotation_layer_builder.AnnotationLayerBuilder({
pageDiv, pageDiv,
pdfPage, pdfPage,
@ -10645,7 +10675,7 @@ class BaseViewer {
linkService: this.linkService, linkService: this.linkService,
downloadManager: this.downloadManager, downloadManager: this.downloadManager,
l10n, l10n,
enableScripting, enableScripting: enableScripting ?? this.enableScripting,
hasJSActionsPromise: hasJSActionsPromise || this.pdfDocument?.hasJSActions(), hasJSActionsPromise: hasJSActionsPromise || this.pdfDocument?.hasJSActions(),
mouseState: mouseState || this._scriptingManager?.mouseState mouseState: mouseState || this._scriptingManager?.mouseState
}); });
@ -10658,6 +10688,12 @@ class BaseViewer {
}); });
} }
createStructTreeLayerBuilder(pdfPage) {
return new _struct_tree_layer_builder.StructTreeLayerBuilder({
pdfPage
});
}
get hasEqualPageSizes() { get hasEqualPageSizes() {
const firstPageView = this._pages[0]; const firstPageView = this._pages[0];
@ -11187,7 +11223,8 @@ const DEFAULT_L10N_STRINGS = {
unexpected_response_error: "Unexpected server response.", unexpected_response_error: "Unexpected server response.",
printing_not_supported: "Warning: Printing is not fully supported by this browser.", printing_not_supported: "Warning: Printing is not fully supported by this browser.",
printing_not_ready: "Warning: The PDF is not fully loaded for printing.", printing_not_ready: "Warning: The PDF is not fully loaded for printing.",
web_fonts_disabled: "Web fonts are disabled: unable to use embedded PDF fonts." web_fonts_disabled: "Web fonts are disabled: unable to use embedded PDF fonts.",
unsupported_feature_signatures: "This PDF document contains digital signatures. Validation of signatures is not supported."
}; };
function getL10nFallback(key, args) { function getL10nFallback(key, args) {
@ -11279,10 +11316,10 @@ class PDFPageView {
this.textLayerFactory = options.textLayerFactory; this.textLayerFactory = options.textLayerFactory;
this.annotationLayerFactory = options.annotationLayerFactory; this.annotationLayerFactory = options.annotationLayerFactory;
this.xfaLayerFactory = options.xfaLayerFactory; this.xfaLayerFactory = options.xfaLayerFactory;
this.structTreeLayerFactory = options.structTreeLayerFactory;
this.renderer = options.renderer || _ui_utils.RendererType.CANVAS; this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
this.enableWebGL = options.enableWebGL || false; this.enableWebGL = options.enableWebGL || false;
this.l10n = options.l10n || _l10n_utils.NullL10n; this.l10n = options.l10n || _l10n_utils.NullL10n;
this.enableScripting = options.enableScripting === true;
this.paintTask = null; this.paintTask = null;
this.paintedViewportMap = new WeakMap(); this.paintedViewportMap = new WeakMap();
this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL; this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
@ -11292,6 +11329,7 @@ class PDFPageView {
this.textLayer = null; this.textLayer = null;
this.zoomLayer = null; this.zoomLayer = null;
this.xfaLayer = null; this.xfaLayer = null;
this.structTreeLayer = null;
const div = document.createElement("div"); const div = document.createElement("div");
div.className = "page"; div.className = "page";
div.style.width = Math.floor(this.viewport.width) + "px"; div.style.width = Math.floor(this.viewport.width) + "px";
@ -11512,6 +11550,12 @@ class PDFPageView {
this.annotationLayer.cancel(); this.annotationLayer.cancel();
this.annotationLayer = null; this.annotationLayer = null;
} }
if (this._onTextLayerRendered) {
this.eventBus._off("textlayerrendered", this._onTextLayerRendered);
this._onTextLayerRendered = null;
}
} }
cssTransform(target, redrawAnnotations = false) { cssTransform(target, redrawAnnotations = false) {
@ -11702,11 +11746,12 @@ class PDFPageView {
const paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper); const paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
paintTask.onRenderContinue = renderContinueCallback; paintTask.onRenderContinue = renderContinueCallback;
this.paintTask = paintTask; this.paintTask = paintTask;
const resultPromise = paintTask.promise.then(function () { const resultPromise = paintTask.promise.then(() => {
return finishPaintTask(null).then(function () { return finishPaintTask(null).then(() => {
if (textLayer) { if (textLayer) {
const readableStream = pdfPage.streamTextContent({ const readableStream = pdfPage.streamTextContent({
normalizeWhitespace: true normalizeWhitespace: true,
includeMarkedContent: true
}); });
textLayer.setTextContentStream(readableStream); textLayer.setTextContentStream(readableStream);
textLayer.render(); textLayer.render();
@ -11718,7 +11763,7 @@ class PDFPageView {
if (this.annotationLayerFactory) { if (this.annotationLayerFactory) {
if (!this.annotationLayer) { if (!this.annotationLayer) {
this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, null, this.imageResourcesPath, this.renderInteractiveForms, this.l10n, this.enableScripting, null, null); this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, null, this.imageResourcesPath, this.renderInteractiveForms, this.l10n, null, null, null);
} }
this._renderAnnotationLayer(); this._renderAnnotationLayer();
@ -11732,6 +11777,31 @@ class PDFPageView {
this._renderXfaLayer(); this._renderXfaLayer();
} }
if (this.structTreeLayerFactory && this.textLayer && this.canvas) {
this._onTextLayerRendered = event => {
if (event.pageNumber !== this.id) {
return;
}
this.eventBus._off("textlayerrendered", this._onTextLayerRendered);
this._onTextLayerRendered = null;
this.pdfPage.getStructTree().then(tree => {
if (!tree) {
return;
}
const treeDom = this.structTreeLayer.render(tree);
treeDom.classList.add("structTree");
this.canvas.appendChild(treeDom);
});
};
this.eventBus._on("textlayerrendered", this._onTextLayerRendered);
this.structTreeLayer = this.structTreeLayerFactory.createStructTreeLayerBuilder(pdfPage);
}
div.setAttribute("data-loaded", true); div.setAttribute("data-loaded", true);
this.eventBus.dispatch("pagerender", { this.eventBus.dispatch("pagerender", {
source: this, source: this,
@ -11863,6 +11933,132 @@ exports.PDFPageView = PDFPageView;
/***/ }), /***/ }),
/* 32 */ /* 32 */
/***/ ((__unused_webpack_module, exports) => {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.StructTreeLayerBuilder = exports.DefaultStructTreeLayerFactory = void 0;
const PDF_ROLE_TO_HTML_ROLE = {
Document: null,
DocumentFragment: null,
Part: "group",
Sect: "group",
Div: "group",
Aside: "note",
NonStruct: "none",
P: null,
H: "heading",
Title: null,
FENote: "note",
Sub: "group",
Lbl: null,
Span: null,
Em: null,
Strong: null,
Link: "link",
Annot: "note",
Form: "form",
Ruby: null,
RB: null,
RT: null,
RP: null,
Warichu: null,
WT: null,
WP: null,
L: "list",
LI: "listitem",
LBody: null,
Table: "table",
TR: "row",
TH: "columnheader",
TD: "cell",
THead: "columnheader",
TBody: null,
TFoot: null,
Caption: null,
Figure: "figure",
Formula: null,
Artifact: null
};
const HEADING_PATTERN = /^H(\d+)$/;
class StructTreeLayerBuilder {
constructor({
pdfPage
}) {
this.pdfPage = pdfPage;
}
render(structTree) {
return this._walk(structTree);
}
_setAttributes(structElement, htmlElement) {
if (structElement.alt !== undefined) {
htmlElement.setAttribute("aria-label", structElement.alt);
}
if (structElement.id !== undefined) {
htmlElement.setAttribute("aria-owns", structElement.id);
}
}
_walk(node) {
if (!node) {
return null;
}
const element = document.createElement("span");
if ("role" in node) {
const {
role
} = node;
const match = role.match(HEADING_PATTERN);
if (match) {
element.setAttribute("role", "heading");
element.setAttribute("aria-level", match[1]);
} else if (PDF_ROLE_TO_HTML_ROLE[role]) {
element.setAttribute("role", PDF_ROLE_TO_HTML_ROLE[role]);
}
}
this._setAttributes(node, element);
if (node.children) {
if (node.children.length === 1 && "id" in node.children[0]) {
this._setAttributes(node.children[0], element);
} else {
for (const kid of node.children) {
element.appendChild(this._walk(kid));
}
}
}
return element;
}
}
exports.StructTreeLayerBuilder = StructTreeLayerBuilder;
class DefaultStructTreeLayerFactory {
createStructTreeLayerBuilder(pdfPage) {
return new StructTreeLayerBuilder({
pdfPage
});
}
}
exports.DefaultStructTreeLayerFactory = DefaultStructTreeLayerFactory;
/***/ }),
/* 33 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => { /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
@ -12216,7 +12412,7 @@ class DefaultTextLayerFactory {
exports.DefaultTextLayerFactory = DefaultTextLayerFactory; exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
/***/ }), /***/ }),
/* 33 */ /* 34 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => { /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
@ -12295,7 +12491,7 @@ class DefaultXfaLayerFactory {
exports.DefaultXfaLayerFactory = DefaultXfaLayerFactory; exports.DefaultXfaLayerFactory = DefaultXfaLayerFactory;
/***/ }), /***/ }),
/* 34 */ /* 35 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => { /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
@ -12309,7 +12505,7 @@ var _ui_utils = __webpack_require__(4);
var _pdf_cursor_tools = __webpack_require__(6); var _pdf_cursor_tools = __webpack_require__(6);
var _pdf_single_page_viewer = __webpack_require__(35); var _pdf_single_page_viewer = __webpack_require__(36);
class SecondaryToolbar { class SecondaryToolbar {
constructor(options, mainContainer, eventBus) { constructor(options, mainContainer, eventBus) {
@ -12614,7 +12810,7 @@ class SecondaryToolbar {
exports.SecondaryToolbar = SecondaryToolbar; exports.SecondaryToolbar = SecondaryToolbar;
/***/ }), /***/ }),
/* 35 */ /* 36 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => { /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
@ -12743,7 +12939,7 @@ class PDFSinglePageViewer extends _base_viewer.BaseViewer {
exports.PDFSinglePageViewer = PDFSinglePageViewer; exports.PDFSinglePageViewer = PDFSinglePageViewer;
/***/ }), /***/ }),
/* 36 */ /* 37 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => { /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
@ -13011,7 +13207,7 @@ class Toolbar {
exports.Toolbar = Toolbar; exports.Toolbar = Toolbar;
/***/ }), /***/ }),
/* 37 */ /* 38 */
/***/ ((__unused_webpack_module, exports) => { /***/ ((__unused_webpack_module, exports) => {
@ -13106,7 +13302,7 @@ class ViewHistory {
exports.ViewHistory = ViewHistory; exports.ViewHistory = ViewHistory;
/***/ }), /***/ }),
/* 38 */ /* 39 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => { /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
@ -13116,13 +13312,13 @@ Object.defineProperty(exports, "__esModule", ({
})); }));
exports.FirefoxCom = exports.DownloadManager = void 0; exports.FirefoxCom = exports.DownloadManager = void 0;
__webpack_require__(39); __webpack_require__(40);
var _app = __webpack_require__(3); var _app = __webpack_require__(3);
var _pdfjsLib = __webpack_require__(5); var _pdfjsLib = __webpack_require__(5);
var _preferences = __webpack_require__(40); var _preferences = __webpack_require__(41);
var _ui_utils = __webpack_require__(4); var _ui_utils = __webpack_require__(4);
@ -13530,7 +13726,7 @@ document.mozL10n.setExternalLocalizerServices({
}); });
/***/ }), /***/ }),
/* 39 */ /* 40 */
/***/ (() => { /***/ (() => {
@ -13652,7 +13848,7 @@ document.mozL10n.setExternalLocalizerServices({
})(void 0); })(void 0);
/***/ }), /***/ }),
/* 40 */ /* 41 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => { /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
@ -13785,7 +13981,7 @@ class BasePreferences {
exports.BasePreferences = BasePreferences; exports.BasePreferences = BasePreferences;
/***/ }), /***/ }),
/* 41 */ /* 42 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => { /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
@ -13830,7 +14026,7 @@ function composePage(pdfDocument, pageNumber, size, printContainer, printResolut
rotation: size.rotation rotation: size.rotation
}), }),
intent: "print", intent: "print",
annotationStorage: pdfDocument.annotationStorage, includeAnnotationStorage: true,
optionalContentConfigPromise optionalContentConfigPromise
}; };
currentRenderTask = thisRenderTask = pdfPage.render(renderContext); currentRenderTask = thisRenderTask = pdfPage.render(renderContext);
@ -13959,15 +14155,15 @@ var _app_options = __webpack_require__(1);
var _app = __webpack_require__(3); var _app = __webpack_require__(3);
const pdfjsVersion = '2.8.320'; const pdfjsVersion = '2.9.44';
const pdfjsBuild = 'ca7f54682'; const pdfjsBuild = '6cf307000';
window.PDFViewerApplication = _app.PDFViewerApplication; window.PDFViewerApplication = _app.PDFViewerApplication;
window.PDFViewerApplicationOptions = _app_options.AppOptions; window.PDFViewerApplicationOptions = _app_options.AppOptions;
; ;
{ {
__webpack_require__(38); __webpack_require__(39);
__webpack_require__(41); __webpack_require__(42);
} }
; ;
; ;

Просмотреть файл

@ -20,7 +20,7 @@ origin:
# Human-readable identifier for this version/release # Human-readable identifier for this version/release
# Generally "version NNN", "tag SSS", "bookmark SSS" # Generally "version NNN", "tag SSS", "bookmark SSS"
release: version 2.8.320 release: version 2.9.44
# The package's license, where possible using the mnemonic from # The package's license, where possible using the mnemonic from
# https://spdx.org/licenses/ # https://spdx.org/licenses/