Skip to content

Commit

Permalink
Update PDFAcroCheckBox.ts
Browse files Browse the repository at this point in the history
Can set value when checkbox as multiple widget
  • Loading branch information
MockingMagician authored Oct 2, 2024
1 parent 93dd36e commit 9431812
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/core/acroform/PDFAcroCheckBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class PDFAcroCheckBox extends PDFAcroButton {
};

setValue(value: PDFName) {
const onValue = this.getOnValue() ?? PDFName.of('Yes');
if (value !== onValue && value !== PDFName.of('Off')) {
const onValue = this.getOnValue().in ?? PDFName.of('Yes');
if (!onValue.includes(value) && value !== PDFName.of('Off')) {
throw new InvalidAcroFieldValueError();
}

Expand All @@ -40,9 +40,8 @@ class PDFAcroCheckBox extends PDFAcroButton {
return PDFName.of('Off');
}

getOnValue(): PDFName | undefined {
const [widget] = this.getWidgets();
return widget?.getOnValue();
getOnValue(): PDFName[] {
return this.getWidgets().map((widget) => widget.getOnValue());
}
}

Expand Down

0 comments on commit 9431812

Please sign in to comment.