Skip to content

Commit

Permalink
Merge pull request #4396 from James-Yu:pdfjs-4.6.82
Browse files Browse the repository at this point in the history
Upgrade to PDF.js 4.6.82
  • Loading branch information
James-Yu authored Sep 19, 2024
2 parents e268d77 + a97e716 commit 0487822
Show file tree
Hide file tree
Showing 67 changed files with 6,425 additions and 2,033 deletions.
2 changes: 1 addition & 1 deletion dev/editviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
.replace('''this.removePageBorders = options.removePageBorders || false;''', '''this.removePageBorders = options.removePageBorders || true;''') \
.replace('''localStorage.setItem("pdfjs.history", databaseStr);''', '''// localStorage.setItem("pdfjs.history", databaseStr);''') \
.replace('''return localStorage.getItem("pdfjs.history");''', '''return // localStorage.getItem("pdfjs.history");''') \
.replace('''this.setTitle(title);''', '''// this.setTitle(title);''') \
.replace('''this.setTitle(title || url);''', '''// this.setTitle(title || url);''') \
.replace('''localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));''', '''// localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));''') \
.replace('''prefs: JSON.parse(localStorage.getItem("pdfjs.preferences"))''', '''prefs: undefined // JSON.parse(localStorage.getItem("pdfjs.preferences"))''') \
.replace('''(!event.shiftKey || window.chrome || window.opera)) {''', '''(!event.shiftKey || window.chrome || window.opera)) {\n if (window.parent !== window) {\n return;\n }''') \
Expand Down
8 changes: 4 additions & 4 deletions dev/viewer/viewer.html.diff
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/../../web/viewer.html b/../viewer/viewer.html
index badac98dc..bedfdd304 100644
index 7c05f0ac5..4369c642c 100644
--- a/../../web/viewer.html
+++ b/../viewer/viewer.html
@@ -25,15 +25,17 @@ See https://github.com/adobe-type-tools/cmap-resources
Expand All @@ -22,12 +22,12 @@ index badac98dc..bedfdd304 100644
</head>

<body tabindex="1">
@@ -275,7 +277,7 @@ See https://github.com/adobe-type-tools/cmap-resources
<button id="sidebarToggle" class="toolbarButton" title="Toggle Sidebar" tabindex="11" data-l10n-id="pdfjs-toggle-sidebar-button" aria-expanded="false" aria-controls="sidebarContainer">
@@ -280,7 +282,7 @@ See https://github.com/adobe-type-tools/cmap-resources
<button id="sidebarToggle" class="toolbarButton" type="button" title="Toggle Sidebar" tabindex="11" data-l10n-id="pdfjs-toggle-sidebar-button" aria-expanded="false" aria-controls="sidebarContainer">
<span data-l10n-id="pdfjs-toggle-sidebar-button-label">Toggle Sidebar</span>
</button>
- <div class="toolbarButtonSpacer"></div>
+ <!-- <div class="toolbarButtonSpacer"></div> -->
<button id="viewFind" class="toolbarButton" title="Find in Document" tabindex="12" data-l10n-id="pdfjs-findbar-button" aria-expanded="false" aria-controls="findbar">
<button id="viewFind" class="toolbarButton" type="button" title="Find in Document" tabindex="12" data-l10n-id="pdfjs-findbar-button" aria-expanded="false" aria-controls="findbar">
<span data-l10n-id="pdfjs-findbar-button-label">Find</span>
</button>
60 changes: 30 additions & 30 deletions dev/viewer/viewer.mjs.diff
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/../../web/viewer.mjs b/../viewer/viewer.mjs
index da30c00c4..00c98d358 100644
index f6fcf25fc..743ed5ce4 100644
--- a/../../web/viewer.mjs
+++ b/../viewer/viewer.mjs
@@ -715,7 +715,7 @@ const defaultOptions = {
@@ -763,7 +763,7 @@ const defaultOptions = {
kind: OptionKind.API
},
cMapUrl: {
Expand All @@ -11,16 +11,16 @@ index da30c00c4..00c98d358 100644
kind: OptionKind.API
},
disableAutoFetch: {
@@ -763,7 +763,7 @@ const defaultOptions = {
@@ -815,7 +815,7 @@ const defaultOptions = {
kind: OptionKind.API
},
standardFontDataUrl: {
- value: "../web/standard_fonts/",
+ value: "../standard_fonts/",
kind: OptionKind.API
},
verbosity: {
@@ -775,7 +775,7 @@ const defaultOptions = {
useSystemFonts: {
@@ -832,7 +832,7 @@ const defaultOptions = {
kind: OptionKind.WORKER
},
workerSrc: {
Expand All @@ -29,7 +29,7 @@ index da30c00c4..00c98d358 100644
kind: OptionKind.WORKER
}
};
@@ -785,7 +785,7 @@ const defaultOptions = {
@@ -842,7 +842,7 @@ const defaultOptions = {
kind: OptionKind.VIEWER
};
defaultOptions.sandboxBundleSrc = {
Expand All @@ -38,7 +38,7 @@ index da30c00c4..00c98d358 100644
kind: OptionKind.VIEWER
};
defaultOptions.viewerCssTheme = {
@@ -2592,7 +2592,7 @@ class Localization {
@@ -2619,7 +2619,7 @@ class Localization {
if (typeof console !== "undefined") {
const locale = bundle.locales[0];
const ids = Array.from(missingIds).join(", ");
Expand All @@ -47,7 +47,7 @@ index da30c00c4..00c98d358 100644
}
}
if (!hasAtLeastOneBundle && typeof console !== "undefined") {
@@ -3054,11 +3054,11 @@ class GenericScripting {
@@ -3099,11 +3099,11 @@ class GenericScripting {
function initCom(app) {}
class Preferences extends BasePreferences {
async _writeToStorage(prefObj) {
Expand All @@ -61,7 +61,7 @@ index da30c00c4..00c98d358 100644
};
}
}
@@ -4475,7 +4475,7 @@ const FindState = {
@@ -5138,7 +5138,7 @@ const FindState = {
PENDING: 3
};
const FIND_TIMEOUT = 250;
Expand All @@ -70,7 +70,7 @@ index da30c00c4..00c98d358 100644
const MATCH_SCROLL_OFFSET_LEFT = -400;
const CHARACTERS_TO_NORMALIZE = {
"\u2010": "-",
@@ -6840,6 +6840,9 @@ function renderProgress(index, total) {
@@ -7518,6 +7518,9 @@ function renderProgress(index, total) {
}
window.addEventListener("keydown", function (event) {
if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
Expand All @@ -80,7 +80,7 @@ index da30c00c4..00c98d358 100644
window.print();
event.preventDefault();
event.stopImmediatePropagation();
@@ -7425,7 +7428,7 @@ class PDFSidebar {
@@ -8102,7 +8105,7 @@ class PDFSidebar {
this.#dispatchEvent();
return;
}
Expand All @@ -89,24 +89,24 @@ index da30c00c4..00c98d358 100644
if (!this.isInitialEventDispatched) {
this.#dispatchEvent();
}
@@ -9975,7 +9978,7 @@ class PDFViewer {
this.#enableHighlightFloatingButton = options.enableHighlightFloatingButton === true;
@@ -10714,7 +10717,7 @@ class PDFViewer {
this.#enableNewAltTextWhenAddingImage = options.enableNewAltTextWhenAddingImage === true;
this.imageResourcesPath = options.imageResourcesPath || "";
this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
- this.removePageBorders = options.removePageBorders || false;
+ this.removePageBorders = options.removePageBorders || true;
this.maxCanvasPixels = options.maxCanvasPixels;
this.l10n = options.l10n;
this.l10n ||= new genericl10n_GenericL10n();
@@ -10275,6 +10278,7 @@ class PDFViewer {
@@ -11028,6 +11031,7 @@ class PDFViewer {
}
}
setDocument(pdfDocument) {
+ const oldScale = lwRecordRender(this);
if (this.pdfDocument) {
this.eventBus.dispatch("pagesdestroy", {
source: this
@@ -10343,7 +10347,7 @@ class PDFViewer {
@@ -11094,7 +11098,7 @@ class PDFViewer {
eventBus._on("pagerendered", onAfterDraw, {
signal
});
Expand All @@ -115,7 +115,7 @@ index da30c00c4..00c98d358 100644
if (pdfDocument !== this.pdfDocument) {
return;
}
@@ -10377,7 +10381,7 @@ class PDFViewer {
@@ -11131,7 +11135,7 @@ class PDFViewer {
}
}
const viewerElement = this._scrollMode === ScrollMode.PAGE ? null : viewer;
Expand All @@ -124,15 +124,15 @@ index da30c00c4..00c98d358 100644
const viewport = firstPdfPage.getViewport({
scale: scale * PixelsPerInch.PDF_TO_CSS_UNITS
});
@@ -10406,6 +10410,7 @@ class PDFViewer {
@@ -11161,6 +11165,7 @@ class PDFViewer {
this._pages.push(pageView);
}
this._pages[0]?.setPdfPage(firstPdfPage);
+ await lwRenderSync(this, pdfDocument, pagesCount);
if (this._scrollMode === ScrollMode.PAGE) {
this.#ensurePageViewVisible();
} else if (this._spreadMode !== SpreadMode.NONE) {
@@ -10498,7 +10503,7 @@ class PDFViewer {
@@ -11253,7 +11258,7 @@ class PDFViewer {
this._pages = [];
this._currentPageNumber = 1;
this._currentScale = UNKNOWN_SCALE;
Expand All @@ -141,7 +141,7 @@ index da30c00c4..00c98d358 100644
this._pageLabels = null;
this.#buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
this._location = null;
@@ -10517,7 +10522,7 @@ class PDFViewer {
@@ -11272,7 +11277,7 @@ class PDFViewer {
};
this.#eventAbortController?.abort();
this.#eventAbortController = null;
Expand All @@ -150,7 +150,7 @@ index da30c00c4..00c98d358 100644
this._updateScrollMode();
this.viewer.removeAttribute("lang");
this.#hiddenCopyElement?.remove();
@@ -10697,8 +10702,8 @@ class PDFViewer {
@@ -11453,8 +11458,8 @@ class PDFViewer {
} else if (this._scrollMode === ScrollMode.HORIZONTAL) {
[hPadding, vPadding] = [vPadding, hPadding];
}
Expand All @@ -161,7 +161,7 @@ index da30c00c4..00c98d358 100644
switch (value) {
case "page-actual":
scale = 1;
@@ -11946,10 +11951,10 @@ class ViewHistory {
@@ -12793,10 +12798,10 @@ class ViewHistory {
}
async _writeToStorage() {
const databaseStr = JSON.stringify(this.database);
Expand All @@ -174,16 +174,16 @@ index da30c00c4..00c98d358 100644
}
async set(name, val) {
await this._initializedPromise;
@@ -12524,7 +12529,7 @@ const PDFViewerApplication = {
title = url;
}
@@ -13381,7 +13386,7 @@ const PDFViewerApplication = {
title = decodeURIComponent(getFilenameFromUrl(url));
} catch {}
}
- this.setTitle(title);
+ // this.setTitle(title);
- this.setTitle(title || url);
+ // this.setTitle(title || url);
},
setTitle(title = this._title) {
this._title = title;
@@ -12971,7 +12976,7 @@ const PDFViewerApplication = {
@@ -13805,7 +13810,7 @@ const PDFViewerApplication = {
this.metadata = metadata;
this._contentDispositionFilename ??= contentDispositionFilename;
this._contentLength ??= contentLength;
Expand All @@ -192,7 +192,7 @@ index da30c00c4..00c98d358 100644
let pdfTitle = info.Title;
const metadataTitle = metadata?.get("dc:title");
if (metadataTitle) {
@@ -13102,9 +13107,9 @@ const PDFViewerApplication = {
@@ -13936,9 +13941,9 @@ const PDFViewerApplication = {
this.pdfSidebar?.setInitialView(sidebarView);
setViewerModes(scrollMode, spreadMode);
if (this.initialBookmark) {
Expand All @@ -204,7 +204,7 @@ index da30c00c4..00c98d358 100644
this.initialBookmark = null;
} else if (storedHash) {
setRotation(rotation);
@@ -14419,7 +14424,7 @@ function webViewerLoad() {
@@ -15199,7 +15204,7 @@ function webViewerLoad() {
try {
parent.document.dispatchEvent(event);
} catch (ex) {
Expand All @@ -213,7 +213,7 @@ index da30c00c4..00c98d358 100644
document.dispatchEvent(event);
}
PDFViewerApplication.run(config);
@@ -14436,4 +14441,3 @@ var __webpack_exports__PDFViewerApplicationConstants = __webpack_exports__.PDFVi
@@ -15216,4 +15221,3 @@ var __webpack_exports__PDFViewerApplicationConstants = __webpack_exports__.PDFVi
var __webpack_exports__PDFViewerApplicationOptions = __webpack_exports__.PDFViewerApplicationOptions;
export { __webpack_exports__PDFViewerApplication as PDFViewerApplication, __webpack_exports__PDFViewerApplicationConstants as PDFViewerApplicationConstants, __webpack_exports__PDFViewerApplicationOptions as PDFViewerApplicationOptions };

Expand Down
18 changes: 10 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2640,7 +2640,7 @@
"latex-utensils": "6.2.0",
"mathjax-full": "3.2.2",
"micromatch": "4.0.8",
"pdfjs-dist": "4.3.136",
"pdfjs-dist": "4.6.82",
"tmp": "0.2.3",
"workerpool": "9.1.3",
"ws": "8.18.0"
Expand Down
6 changes: 3 additions & 3 deletions viewer/components/gui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ export function patchViewerUI() {

const template = document.createElement('template')
template.innerHTML =
`<button id="TrimButton" class="secondaryToolbarButton" title="${getL10n('trimMargin')}" tabindex="70">
`<button id="TrimButton" class="toolbarButton labeled" type="button" title="${getL10n('trimMargin')}" tabindex="70">
<label for="trimPct">${getL10n('trimMargin')}</label>
<input type="number" id="trimPct" name="trimPct" min="0" max="99" value="0">
<label for="trimPct">%</label>
</button>
<button id="synctexOnButton" class="secondaryToolbarButton" title="${getL10n('enableSyncTeX')}" tabindex="71">
<button id="synctexOnButton" class="toolbarButton labeled" type="button" title="${getL10n('enableSyncTeX')}" tabindex="71">
<input id="synctexOn" type="checkbox" checked><span>${getL10n('enableSyncTeX')}</span>
</button>
<button id="autoRefreshOnButton" class="secondaryToolbarButton" title="${getL10n('enableRefresh')}" tabindex="72">
<button id="autoRefreshOnButton" class="toolbarButton labeled" type="button" title="${getL10n('enableRefresh')}" tabindex="72">
<input id="autoRefreshOn" type="checkbox" checked><span>${getL10n('enableRefresh')}</span>
</button>
<div class="horizontalToolbarSeparator"></div>`
Expand Down
3 changes: 3 additions & 0 deletions viewer/images/altText_disclaimer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0487822

Please sign in to comment.