From b0b0de98e737fb39c9b1cff9a82b78689959af42 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Thu, 21 Nov 2024 17:27:31 +0100 Subject: [PATCH] Use the V entry as an option when no options in a choice widget It fixes #19083. It isn't really a fix but more a workaround (we should correctly implement the choice widget as a mix of text input+select). --- src/core/annotation.js | 12 ++++++++++++ test/pdfs/.gitignore | 1 + test/pdfs/issue19083.pdf | Bin 0 -> 6673 bytes test/test_manifest.json | 9 +++++++++ 4 files changed, 22 insertions(+) create mode 100755 test/pdfs/issue19083.pdf diff --git a/src/core/annotation.js b/src/core/annotation.js index 3a7c9ccdf7ed4..e970dc34cddd4 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -3511,6 +3511,18 @@ class ChoiceWidgetAnnotation extends WidgetAnnotation { } } + // It's a workaround for the issue #19083. + // Normally a choice widget is a mix of a text field and a listbox, + // So in the case where the V entry isn't an option we should just set it + // as the text field value. + if (this.data.options.length === 0 && this.data.fieldValue.length > 0) { + // If there are no options, then the field value is the only option. + this.data.options = this.data.fieldValue.map(value => ({ + exportValue: value, + displayValue: value, + })); + } + // Process field flags for the display layer. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO); this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT); diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 4bf8b655473e2..0d392f67c82dd 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -681,3 +681,4 @@ !issue18894.pdf !bug1922766.pdf !issue18956.pdf +!issue19083.pdf diff --git a/test/pdfs/issue19083.pdf b/test/pdfs/issue19083.pdf new file mode 100755 index 0000000000000000000000000000000000000000..508b7db9630cd351778d3d6b31cd618f9fe735a2 GIT binary patch literal 6673 zcmeHMc~nzp7H3BzpklQk9erhSDM{X*O^A{N1cZVRM8$V{h_ z$8jyT>Zl`CDPqT3IJh7#P_?#L#%f*Ax>RemXm!4qfW#W7^_=NB^M{;6&Rg!i-@U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