* Set the text value. * * This method is async because it regenerates the field's appearance * stream after setting the value. * * @param value The new text value * @throws {Error} if field is read-only
(value: string)
| 96 | * @throws {Error} if field is read-only |
| 97 | */ |
| 98 | setValue(value: string): void { |
| 99 | this.assertWritable(); |
| 100 | |
| 101 | // Truncate if maxLength is set |
| 102 | const finalValue = this.maxLength > 0 ? value.slice(0, this.maxLength) : value; |
| 103 | |
| 104 | // Set /V on field dict |
| 105 | this.dict.set("V", PdfString.fromString(finalValue)); |
| 106 | this.needsAppearanceUpdate = true; |
| 107 | |
| 108 | // Regenerate appearance immediately |
| 109 | this.applyChange(); |
| 110 | } |
| 111 | } |
no test coverage detected