1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 01:58:06 +02:00

Display widget signature

- but don't validate them for now;
  - Firefox will display a bar to warn that the signature validation is not supported (see https://bugzilla.mozilla.org/show_bug.cgi?id=854315)
  - almost all (all ?) pdf readers display signatures;
  - validation is done in edge but for now it's behind a pref.
This commit is contained in:
Calixte Denizet 2021-04-10 16:53:17 +02:00
parent 6ddc297170
commit 5875ebb1ca
10 changed files with 58 additions and 19 deletions

View file

@ -126,6 +126,8 @@ class AnnotationFactory {
return new ButtonWidgetAnnotation(parameters);
case "Ch":
return new ChoiceWidgetAnnotation(parameters);
case "Sig":
return new SignatureWidgetAnnotation(parameters);
}
warn(
`Unimplemented widget field type "${fieldType}", ` +
@ -1151,15 +1153,6 @@ class WidgetAnnotation extends Annotation {
data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
data.hidden = this._hasFlag(data.annotationFlags, AnnotationFlag.HIDDEN);
// Hide signatures because we cannot validate them, and unset the fieldValue
// since it's (most likely) a `Dict` which is non-serializable and will thus
// cause errors when sending annotations to the main-thread (issue 10347).
if (data.fieldType === "Sig") {
data.fieldValue = null;
this.setFlags(AnnotationFlag.HIDDEN);
data.hidden = true;
}
}
/**
@ -1201,7 +1194,7 @@ class WidgetAnnotation extends Annotation {
getOperatorList(evaluator, task, renderForms, annotationStorage) {
// Do not render form elements on the canvas when interactive forms are
// enabled. The display layer is responsible for rendering them instead.
if (renderForms) {
if (renderForms && !(this instanceof SignatureWidgetAnnotation)) {
return Promise.resolve(new OperatorList());
}
@ -1600,13 +1593,6 @@ class WidgetAnnotation extends Annotation {
}
getFieldObject() {
if (this.data.fieldType === "Sig") {
return {
id: this.data.id,
value: null,
type: "signature",
};
}
return null;
}
}
@ -2203,6 +2189,25 @@ class ChoiceWidgetAnnotation extends WidgetAnnotation {
}
}
class SignatureWidgetAnnotation extends WidgetAnnotation {
constructor(params) {
super(params);
// Unset the fieldValue since it's (most likely) a `Dict` which is
// non-serializable and will thus cause errors when sending annotations
// to the main-thread (issue 10347).
this.data.fieldValue = null;
}
getFieldObject() {
return {
id: this.data.id,
value: null,
type: "signature",
};
}
}
class TextAnnotation extends MarkupAnnotation {
constructor(parameters) {
const DEFAULT_ICON_SIZE = 22; // px