Merge pull request #19390 from Snuffleupagus/issue-19389

Support the password field-flag in TextWidgetAnnotation (issue 19389)
This commit is contained in:
Jonas Jenwald 2025-01-29 14:41:19 +01:00 committed by GitHub
commit 9bc4331485
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 13 additions and 4 deletions

View File

@ -1888,6 +1888,7 @@ class WidgetAnnotation extends Annotation {
data.fieldFlags = 0; data.fieldFlags = 0;
} }
data.password = this.hasFieldFlag(AnnotationFieldFlag.PASSWORD);
data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY); data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
data.required = this.hasFieldFlag(AnnotationFieldFlag.REQUIRED); data.required = this.hasFieldFlag(AnnotationFieldFlag.REQUIRED);
data.hidden = data.hidden =
@ -2261,8 +2262,7 @@ class WidgetAnnotation extends Annotation {
} }
async _getAppearance(evaluator, task, intent, annotationStorage) { async _getAppearance(evaluator, task, intent, annotationStorage) {
const isPassword = this.hasFieldFlag(AnnotationFieldFlag.PASSWORD); if (this.data.password) {
if (isPassword) {
return null; return null;
} }
const storageEntry = annotationStorage?.get(this.data.id); const storageEntry = annotationStorage?.get(this.data.id);
@ -2962,7 +2962,7 @@ class TextWidgetAnnotation extends WidgetAnnotation {
value: this.data.fieldValue, value: this.data.fieldValue,
defaultValue: this.data.defaultFieldValue || "", defaultValue: this.data.defaultFieldValue || "",
multiline: this.data.multiLine, multiline: this.data.multiLine,
password: this.hasFieldFlag(AnnotationFieldFlag.PASSWORD), password: this.data.password,
charLimit: this.data.maxLen, charLimit: this.data.maxLen,
comb: this.data.comb, comb: this.data.comb,
editable: !this.data.readOnly, editable: !this.data.readOnly,

View File

@ -1286,7 +1286,7 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
} }
} else { } else {
element = document.createElement("input"); element = document.createElement("input");
element.type = "text"; element.type = this.data.password ? "password" : "text";
element.setAttribute("value", fieldFormattedValues ?? textContent); element.setAttribute("value", fieldFormattedValues ?? textContent);
if (this.data.doNotScroll) { if (this.data.doNotScroll) {
element.style.overflowX = "hidden"; element.style.overflowX = "hidden";

View File

@ -609,6 +609,7 @@
!issue16021.pdf !issue16021.pdf
!bug1770750.pdf !bug1770750.pdf
!issue16063.pdf !issue16063.pdf
!issue19389.pdf
!issue16067.pdf !issue16067.pdf
!bug1820909.1.pdf !bug1820909.1.pdf
!issue16221.pdf !issue16221.pdf

BIN
test/pdfs/issue19389.pdf Normal file

Binary file not shown.

View File

@ -1251,6 +1251,14 @@
"type": "eq", "type": "eq",
"about": "XObject with BBox array containing indirect object." "about": "XObject with BBox array containing indirect object."
}, },
{
"id": "issue19389",
"file": "pdfs/issue19389.pdf",
"md5": "419357cd829b067347c64b9ae838af4a",
"rounds": 1,
"type": "eq",
"forms": true
},
{ {
"id": "issue7115", "id": "issue7115",
"file": "pdfs/issue7115.pdf", "file": "pdfs/issue7115.pdf",