mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +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:
parent
6ddc297170
commit
5875ebb1ca
10 changed files with 58 additions and 19 deletions
|
@ -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
|
||||
|
|
|
@ -828,7 +828,12 @@ class PDFDocument {
|
|||
}
|
||||
|
||||
get formInfo() {
|
||||
const formInfo = { hasFields: false, hasAcroForm: false, hasXfa: false };
|
||||
const formInfo = {
|
||||
hasFields: false,
|
||||
hasAcroForm: false,
|
||||
hasXfa: false,
|
||||
hasSignatures: false,
|
||||
};
|
||||
const acroForm = this.catalog.acroForm;
|
||||
if (!acroForm) {
|
||||
return shadow(this, "formInfo", formInfo);
|
||||
|
@ -854,9 +859,11 @@ class PDFDocument {
|
|||
// the first bit of the `SigFlags` integer (see Table 219 in the
|
||||
// specification).
|
||||
const sigFlags = acroForm.get("SigFlags");
|
||||
const hasSignatures = !!(sigFlags & 0x1);
|
||||
const hasOnlyDocumentSignatures =
|
||||
!!(sigFlags & 0x1) && this._hasOnlyDocumentSignatures(fields);
|
||||
hasSignatures && this._hasOnlyDocumentSignatures(fields);
|
||||
formInfo.hasAcroForm = hasFields && !hasOnlyDocumentSignatures;
|
||||
formInfo.hasSignatures = hasSignatures;
|
||||
} catch (ex) {
|
||||
if (ex instanceof MissingDataException) {
|
||||
throw ex;
|
||||
|
@ -894,6 +901,7 @@ class PDFDocument {
|
|||
IsAcroFormPresent: this.formInfo.hasAcroForm,
|
||||
IsXFAPresent: this.formInfo.hasXfa,
|
||||
IsCollectionPresent: !!this.catalog.collection,
|
||||
IsSignaturesPresent: this.formInfo.hasSignatures,
|
||||
};
|
||||
|
||||
let infoDict;
|
||||
|
|
|
@ -315,6 +315,7 @@ const UNSUPPORTED_FEATURES = {
|
|||
unknown: "unknown",
|
||||
forms: "forms",
|
||||
javaScript: "javaScript",
|
||||
signatures: "signatures",
|
||||
smask: "smask",
|
||||
shadingPattern: "shadingPattern",
|
||||
/** @deprecated unused */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue