Skip to content

Commit

Permalink
Update pdf.js
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Aug 6, 2023
1 parent e05def6 commit 4d948ee
Show file tree
Hide file tree
Showing 9 changed files with 288 additions and 140 deletions.
295 changes: 212 additions & 83 deletions build/pdf.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions build/pdf.sandbox.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

50 changes: 26 additions & 24 deletions build/pdf.worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class WorkerMessageHandler {
docId,
apiVersion
} = docParams;
const workerVersion = '3.9.0';
const workerVersion = '3.10.0';
if (apiVersion !== workerVersion) {
throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`);
}
Expand Down Expand Up @@ -359,9 +359,6 @@ class WorkerMessageHandler {
handler.on("GetAttachments", function (data) {
return pdfManager.ensureCatalog("attachments");
});
handler.on("GetJavaScript", function (data) {
return pdfManager.ensureCatalog("javaScript");
});
handler.on("GetDocJSActions", function (data) {
return pdfManager.ensureCatalog("jsActions");
});
Expand Down Expand Up @@ -3292,7 +3289,7 @@ class Page {
intentPrint = !!(intent & _util.RenderingIntentFlag.PRINT);
const opListPromises = [];
for (const annotation of annotations) {
if (intentAny || intentDisplay && annotation.mustBeViewed(annotationStorage) || intentPrint && annotation.mustBePrinted(annotationStorage)) {
if (intentAny || intentDisplay && annotation.mustBeViewed(annotationStorage, renderForms) || intentPrint && annotation.mustBePrinted(annotationStorage)) {
opListPromises.push(annotation.getOperatorList(partialEvaluator, task, intent, renderForms, annotationStorage).catch(function (reason) {
(0, _util.warn)("getOperatorList - ignoring annotation data during " + `"${task.name}" task: "${reason}".`);
return {
Expand Down Expand Up @@ -4664,19 +4661,19 @@ class Annotation {
return !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, _util.AnnotationFlag.NOVIEW);
}
_isPrintable(flags) {
return this._hasFlag(flags, _util.AnnotationFlag.PRINT) && !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE);
return this._hasFlag(flags, _util.AnnotationFlag.PRINT) && !this._hasFlag(flags, _util.AnnotationFlag.HIDDEN) && !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE);
}
mustBeViewed(annotationStorage) {
const hidden = annotationStorage?.get(this.data.id)?.hidden;
if (hidden !== undefined) {
return !hidden;
mustBeViewed(annotationStorage, _renderForms) {
const noView = annotationStorage?.get(this.data.id)?.noView;
if (noView !== undefined) {
return !noView;
}
return this.viewable && !this._hasFlag(this.flags, _util.AnnotationFlag.HIDDEN);
}
mustBePrinted(annotationStorage) {
const print = annotationStorage?.get(this.data.id)?.print;
if (print !== undefined) {
return print;
const noPrint = annotationStorage?.get(this.data.id)?.noPrint;
if (noPrint !== undefined) {
return !noPrint;
}
return this.printable;
}
Expand Down Expand Up @@ -5349,7 +5346,7 @@ class WidgetAnnotation extends Annotation {
}
data.readOnly = this.hasFieldFlag(_util.AnnotationFieldFlag.READONLY);
data.required = this.hasFieldFlag(_util.AnnotationFieldFlag.REQUIRED);
data.hidden = this._hasFlag(data.annotationFlags, _util.AnnotationFlag.HIDDEN);
data.hidden = this._hasFlag(data.annotationFlags, _util.AnnotationFlag.HIDDEN) || this._hasFlag(data.annotationFlags, _util.AnnotationFlag.NOVIEW);
}
_decodeFormValue(formValue) {
if (Array.isArray(formValue)) {
Expand All @@ -5364,6 +5361,15 @@ class WidgetAnnotation extends Annotation {
hasFieldFlag(flag) {
return !!(this.data.fieldFlags & flag);
}
_isViewable(flags) {
return !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE);
}
mustBeViewed(annotationStorage, renderForms) {
if (renderForms) {
return this.viewable;
}
return super.mustBeViewed(annotationStorage, renderForms) && !this._hasFlag(this.flags, _util.AnnotationFlag.NOVIEW);
}
getRotationMatrix(annotationStorage) {
let rotation = annotationStorage?.get(this.data.id)?.rotation;
if (rotation === undefined) {
Expand Down Expand Up @@ -44725,7 +44731,9 @@ class Catalog {
return;
}
js = (0, _util.stringToPDFString)(js).replaceAll("\x00", "");
(javaScript ||= new Map()).set(name, js);
if (js) {
(javaScript ||= new Map()).set(name, js);
}
}
if (obj instanceof _primitives.Dict && obj.has("JavaScript")) {
const nameTree = new _name_number_tree.NameTree(obj.getRaw("JavaScript"), this.xref);
Expand All @@ -44739,17 +44747,11 @@ class Catalog {
}
return javaScript;
}
get javaScript() {
const javaScript = this._collectJavaScript();
return (0, _util.shadow)(this, "javaScript", javaScript ? [...javaScript.values()] : null);
}
get jsActions() {
const javaScript = this._collectJavaScript();
let actions = (0, _core_utils.collectActions)(this.xref, this._catDict, _util.DocumentActionEventType);
if (javaScript) {
if (!actions) {
actions = Object.create(null);
}
actions ||= Object.create(null);
for (const [key, val] of javaScript) {
if (key in actions) {
actions[key].push(val);
Expand Down Expand Up @@ -58434,8 +58436,8 @@ Object.defineProperty(exports, "WorkerMessageHandler", ({
}
}));
var _worker = __w_pdfjs_require__(1);
const pdfjsVersion = '3.9.0';
const pdfjsBuild = '7ae5a0f';
const pdfjsVersion = '3.10.0';
const pdfjsBuild = '3994752';
})();

/******/ return __webpack_exports__;
Expand Down
2 changes: 1 addition & 1 deletion build/pdf.worker.js.map

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion web/viewer.css
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@
}

.annotationEditorLayer
:is(.freeTextEditor, .inkEditor, .stampEditor)[draggable="true"] {
:is(.freeTextEditor, .inkEditor, .stampEditor).draggable {
cursor: move;
}

Expand Down Expand Up @@ -1159,6 +1159,12 @@
height: var(--viewer-container-height);
}

.pdfViewer.noUserSelect {
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}

.pdfViewer.removePageBorders .page {
margin: 0 auto 10px;
border: none;
Expand Down
61 changes: 36 additions & 25 deletions web/viewer.js

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

2 changes: 1 addition & 1 deletion web/viewer.js.map

Large diffs are not rendered by default.

0 comments on commit 4d948ee

Please sign in to comment.