Skip to content

Commit

Permalink
Update pdf.js
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Jun 23, 2024
1 parent 11f13e8 commit fb399ef
Show file tree
Hide file tree
Showing 11 changed files with 429 additions and 160 deletions.
351 changes: 267 additions & 84 deletions build/pdf.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/pdf.mjs.map

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions build/pdf.sandbox.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/pdf.sandbox.mjs.map

Large diffs are not rendered by default.

148 changes: 113 additions & 35 deletions build/pdf.worker.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/pdf.worker.mjs.map

Large diffs are not rendered by default.

10 changes: 1 addition & 9 deletions web/locale/is/viewer.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ pdfjs-download-button-label = Sækja
pdfjs-bookmark-button =
.title = Núverandi síða (Skoða vefslóð frá núverandi síðu)
pdfjs-bookmark-button-label = Núverandi síða
# Used in Firefox for Android.
pdfjs-open-in-app-button =
.title = Opna í smáforriti
# Used in Firefox for Android.
# Length of the translation matters since we are in a mobile context, with limited screen estate.
pdfjs-open-in-app-button-label = Opna í smáforriti
## Secondary toolbar and context menu

Expand Down Expand Up @@ -284,7 +278,7 @@ pdfjs-text-annotation-type =
## Password

pdfjs-password-label = Sláðu inn lykilorð til að opna þessa PDF skrá.
pdfjs-password-label = Settu inn lykilorð til að opna þessa PDF-skrá.
pdfjs-password-invalid = Ógilt lykilorð. Reyndu aftur.
pdfjs-password-ok-button = Í lagi
pdfjs-password-cancel-button = Hætta við
Expand All @@ -304,8 +298,6 @@ pdfjs-editor-stamp-button-label = Bæta við eða breyta myndum
pdfjs-editor-highlight-button =
.title = Áherslulita
pdfjs-editor-highlight-button-label = Áherslulita
pdfjs-highlight-floating-button =
.title = Áherslulita
pdfjs-highlight-floating-button1 =
.title = Áherslulita
.aria-label = Áherslulita
Expand Down
2 changes: 1 addition & 1 deletion web/locale/ja/viewer.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ pdfjs-text-annotation-type =
## Password

pdfjs-password-label = この PDF ファイルを開くためのパスワードを入力してください。
pdfjs-password-invalid = 無効なパスワードです。もう一度やり直してください
pdfjs-password-invalid = パスワードが正しくありません。もう一度試してください
pdfjs-password-ok-button = OK
pdfjs-password-cancel-button = キャンセル
pdfjs-web-fonts-disabled = ウェブフォントが無効になっています: 埋め込まれた PDF のフォントを使用できません。
Expand Down
2 changes: 2 additions & 0 deletions web/viewer.css
Original file line number Diff line number Diff line change
Expand Up @@ -1894,6 +1894,8 @@
width:100%;
height:100%;
margin:0;
top:0;
left:0;
}

.annotationEditorLayer :is(.freeTextEditor, .inkEditor, .stampEditor) > .resizers{
Expand Down
61 changes: 36 additions & 25 deletions web/viewer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,8 @@ function approximateFraction(x) {
}
return result;
}
function roundToDivide(x, div) {
const r = x % div;
return r === 0 ? x : Math.round(x - r + div);
function floorToDivide(x, div) {
return x - x % div;
}
function getPageSizeInches({
view,
Expand Down Expand Up @@ -742,7 +741,7 @@ const defaultOptions = {
kind: OptionKind.API
},
enableHWA: {
value: false,
value: true,
kind: OptionKind.API + OptionKind.VIEWER + OptionKind.PREFERENCE
},
enableXfa: {
Expand Down Expand Up @@ -1437,7 +1436,7 @@ class BasePreferences {
disableFontFace: false,
disableRange: false,
disableStream: false,
enableHWA: false,
enableHWA: true,
enableXfa: true,
viewerCssTheme: 0
});
Expand Down Expand Up @@ -2851,6 +2850,7 @@ class DOMLocalization extends Localization {
;// CONCATENATED MODULE: ./web/l10n.js
class L10n {
#dir;
#elements = new Set();
#lang;
#l10n;
constructor({
Expand Down Expand Up @@ -2885,11 +2885,22 @@ class L10n {
return messages?.[0].value || fallback;
}
async translate(element) {
this.#elements.add(element);
try {
this.#l10n.connectRoot(element);
await this.#l10n.translateRoots();
} catch {}
}
async destroy() {
for (const element of this.#elements) {
this.#l10n.disconnectRoot(element);
}
this.#elements.clear();
this.#l10n.pauseObserving();
await new Promise(resolve => {
window.requestAnimationFrame(resolve);
});
}
pause() {
this.#l10n.pauseObserving();
}
Expand Down Expand Up @@ -2962,8 +2973,7 @@ class genericl10n_GenericL10n extends L10n {
const bundle = await this.#createBundle(lang, baseURL, paths);
if (bundle) {
yield bundle;
}
if (lang === "en-us") {
} else if (lang === "en-us") {
yield this.#createBundleFallback(lang);
}
}
Expand Down Expand Up @@ -5192,6 +5202,7 @@ class PDFFindController {
source: this,
state,
previous,
entireWord: this.#state?.entireWord ?? null,
matchesCount: this.#requestMatchesCount(),
rawQuery: this.#state?.query ?? null
});
Expand Down Expand Up @@ -9779,13 +9790,13 @@ class PDFPageView {
}
const sfx = approximateFraction(outputScale.sx);
const sfy = approximateFraction(outputScale.sy);
canvas.width = roundToDivide(width * outputScale.sx, sfx[0]);
canvas.height = roundToDivide(height * outputScale.sy, sfy[0]);
canvas.width = floorToDivide(width * outputScale.sx, sfx[0]);
canvas.height = floorToDivide(height * outputScale.sy, sfy[0]);
const {
style
} = canvas;
style.width = roundToDivide(width, sfx[1]) + "px";
style.height = roundToDivide(height, sfy[1]) + "px";
style.width = floorToDivide(width, sfx[1]) + "px";
style.height = floorToDivide(height, sfy[1]) + "px";
this.#viewportMap.set(canvas, viewport);
const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
const renderContext = {
Expand Down Expand Up @@ -12688,17 +12699,12 @@ const PDFViewerApplication = {
});
});
},
_ensureDownloadComplete() {
if (this.pdfDocument && this.downloadComplete) {
return;
}
throw new Error("PDF document not downloaded.");
},
async download(options = {}) {
let data;
try {
this._ensureDownloadComplete();
data = await this.pdfDocument.getData();
if (this.downloadComplete) {
data = await this.pdfDocument.getData();
}
} catch {}
this.downloadManager.download(data, this._downloadUrl, this._docFilename, options);
},
Expand All @@ -12709,7 +12715,6 @@ const PDFViewerApplication = {
this._saveInProgress = true;
await this.pdfScriptingManager.dispatchWillSave();
try {
this._ensureDownloadComplete();
const data = await this.pdfDocument.saveDocument();
this.downloadManager.download(data, this._downloadUrl, this._docFilename, options);
} catch (reason) {
Expand Down Expand Up @@ -13501,10 +13506,14 @@ const PDFViewerApplication = {
unbindWindowEvents() {
this._windowAbortController?.abort();
this._windowAbortController = null;
if (AppOptions.get("isInAutomation")) {
this._globalAbortController?.abort();
this._globalAbortController = null;
}
},
async testingClose() {
this.unbindEvents();
this.unbindWindowEvents();
this._globalAbortController?.abort();
this._globalAbortController = null;
this.findBar?.close();
await Promise.all([this.l10n?.destroy(), this.close()]);
},
_accumulateTicks(ticks, prop) {
if (this[prop] > 0 && ticks < 0 || this[prop] < 0 && ticks > 0) {
Expand Down Expand Up @@ -13803,13 +13812,15 @@ function webViewerUpdateFindMatchesCount({
function webViewerUpdateFindControlState({
state,
previous,
entireWord,
matchesCount,
rawQuery
}) {
if (PDFViewerApplication.supportsIntegratedFind) {
PDFViewerApplication.externalServices.updateFindControlState({
result: state,
findPrevious: previous,
entireWord,
matchesCount,
rawQuery
});
Expand Down Expand Up @@ -14309,7 +14320,7 @@ function webViewerReportTelemetry({


const pdfjsVersion = "4.4.0";
const pdfjsBuild = "2effc96";
const pdfjsBuild = "c18a987";
const AppConstants = {
LinkTarget: LinkTarget,
RenderingStates: RenderingStates,
Expand Down
2 changes: 1 addition & 1 deletion web/viewer.mjs.map

Large diffs are not rendered by default.

0 comments on commit fb399ef

Please sign in to comment.