Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the password field-flag in TextWidgetAnnotation (issue 19389) #19390

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/core/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1888,6 +1888,7 @@ class WidgetAnnotation extends Annotation {
data.fieldFlags = 0;
}

data.password = this.hasFieldFlag(AnnotationFieldFlag.PASSWORD);
data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
data.required = this.hasFieldFlag(AnnotationFieldFlag.REQUIRED);
data.hidden =
Expand Down Expand Up @@ -2261,8 +2262,7 @@ class WidgetAnnotation extends Annotation {
}

async _getAppearance(evaluator, task, intent, annotationStorage) {
const isPassword = this.hasFieldFlag(AnnotationFieldFlag.PASSWORD);
if (isPassword) {
if (this.data.password) {
return null;
}
const storageEntry = annotationStorage?.get(this.data.id);
Expand Down Expand Up @@ -2962,7 +2962,7 @@ class TextWidgetAnnotation extends WidgetAnnotation {
value: this.data.fieldValue,
defaultValue: this.data.defaultFieldValue || "",
multiline: this.data.multiLine,
password: this.hasFieldFlag(AnnotationFieldFlag.PASSWORD),
password: this.data.password,
charLimit: this.data.maxLen,
comb: this.data.comb,
editable: !this.data.readOnly,
Expand Down
2 changes: 1 addition & 1 deletion src/display/annotation_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
}
} else {
element = document.createElement("input");
element.type = "text";
element.type = this.data.password ? "password" : "text";
element.setAttribute("value", fieldFormattedValues ?? textContent);
if (this.data.doNotScroll) {
element.style.overflowX = "hidden";
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@
!issue16021.pdf
!bug1770750.pdf
!issue16063.pdf
!issue19389.pdf
!issue16067.pdf
!bug1820909.1.pdf
!issue16221.pdf
Expand Down
Binary file added test/pdfs/issue19389.pdf
Binary file not shown.
8 changes: 8 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,14 @@
"type": "eq",
"about": "XObject with BBox array containing indirect object."
},
{
"id": "issue19389",
"file": "pdfs/issue19389.pdf",
"md5": "419357cd829b067347c64b9ae838af4a",
"rounds": 1,
"type": "eq",
"forms": true
},
{
"id": "issue7115",
"file": "pdfs/issue7115.pdf",
Expand Down