MCPcopy Create free account
hub / github.com/LibPDF-js/core / setValue

Method setValue

src/document/forms/fields/text-field.ts:98–110  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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}

Callers 12

acro-form.test.tsFile · 0.45
pdf-form.test.tsFile · 0.45
setFieldValueMethod · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
forms.bench.tsFile · 0.45

Calls 3

sliceMethod · 0.80
setMethod · 0.45
fromStringMethod · 0.45

Tested by

no test coverage detected