From fc925827b2703cbefdc10373680fe49499c2ed8b Mon Sep 17 00:00:00 2001 From: dhufnagel Date: Fri, 12 Feb 2021 11:22:54 +0100 Subject: [PATCH] fix initial state of checkboxes in display layer (#12904) consider the export value when multiple checkboxes have the same name --- src/display/annotation_layer.js | 5 ++++- test/pdfs/issue12716.pdf.link | 1 + test/test_manifest.json | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 test/pdfs/issue12716.pdf.link diff --git a/src/display/annotation_layer.js b/src/display/annotation_layer.js index afef1db5c..3879984b6 100644 --- a/src/display/annotation_layer.js +++ b/src/display/annotation_layer.js @@ -874,7 +874,10 @@ class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement { const data = this.data; const id = data.id; const value = storage.getOrCreateValue(id, { - value: data.fieldValue && data.fieldValue !== "Off", + value: + data.fieldValue && + ((data.exportValue && data.exportValue === data.fieldValue) || + (!data.exportValue && data.fieldValue !== "Off")), }).value; this.container.className = "buttonWidgetAnnotation checkBox"; diff --git a/test/pdfs/issue12716.pdf.link b/test/pdfs/issue12716.pdf.link new file mode 100644 index 000000000..4e73bca65 --- /dev/null +++ b/test/pdfs/issue12716.pdf.link @@ -0,0 +1 @@ +https://github.com/mozilla/pdf.js/files/5670936/form-cms1500.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index 4d9a8d51d..5a893ad2e 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -5038,5 +5038,15 @@ "rounds": 1, "type": "eq", "forms": true + }, + { + "id": "issue12716", + "file": "pdfs/issue12716.pdf", + "md5": "9bdc9c552bcfccd629f5f97385e79ca5", + "rounds": 1, + "link": true, + "type": "eq", + "forms": true, + "lastPage": 1 } ]