forms.validateRequired
Hold back Download while a required field is empty. The toolbar's Download (with or without your
onDownload) does nothing while a required text, choice, check box or radio field is empty: a message names up to three empty fields (by their field names), then a count, and focus moves to the first. Read-only and hidden fields are skipped, and a check box or radio group counts as filled once any of its widgets is on. Signature fields are not checked. viewer.createExporter() is not held back; gate it yourself with doc.forms.getValues(), which carries the live input, and the fields.booleandefault false
Example
validateRequiredTypeScript
import type { FormValue } from '@kernstra/pdf-web-sdk'; // One value per field; a check box or radio group reports 'Off' when nothing is on. const values = await doc.forms.getValues(); const blank = (value: FormValue | undefined): boolean => { if (value === undefined || value === 'Off') return true; return typeof value === 'string' ? value.trim() === '' : value.length === 0; }; const empty = new Set( (await doc.forms.fields()) .filter((field) => field.required && !field.readOnly && blank(values[field.name])) .map((field) => field.name), );