[Annotations] Add support for printing/saving choice list with multiple selections

- it aims to fix issue #12189.
This commit is contained in:
Calixte Denizet 2022-03-26 22:45:50 +01:00
parent 0dd6bc9a85
commit ad3fb71a02
7 changed files with 355 additions and 33 deletions

View file

@ -49,6 +49,9 @@ class EventDispatcher {
mergeChange(event) {
let value = event.value;
if (Array.isArray(value)) {
return value;
}
if (typeof value !== "string") {
value = value.toString();
}

View file

@ -233,7 +233,11 @@ class Field extends PDFObject {
if (this._isChoice) {
if (this.multipleSelection) {
const values = new Set(value);
this._currentValueIndices.length = 0;
if (Array.isArray(this._currentValueIndices)) {
this._currentValueIndices.length = 0;
} else {
this._currentValueIndices = [];
}
this._items.forEach(({ displayValue }, i) => {
if (values.has(displayValue)) {
this._currentValueIndices.push(i);