new FieldManager(annotationManager)
Represents a tree of PDF Forms fields. @see Annotations.Forms.Field
Allows adding, getting and visiting fields.
Parameters:
Name | Type | Description |
---|---|---|
annotationManager |
CoreControls.AnnotationManager |
Methods
-
addField(field [, update])
-
Adds the given field object to the field tree, either replacing or merging with any existing field. Note: if the field is merged, it is the equivalent of performing Annotations.Forms.Field.set on the existing field, followed by setting all the field's widgets' fields to the original field.
Parameters:
Name Type Argument Default Description field
Annotations.Forms.Field | object The field or field-like object to add. update
boolean <optional>
false Returns:
The field that was inserted into the field tree (may not be the field originally provided). -
calculate(field [, index])
-
Equivalent to the given field's value changing, if it was at position index in the calculation order.
Parameters:
Name Type Argument Default Description field
Annotations.Forms.Field <nullable>
The field to set as source for the calculation event. May be null. index
number <optional>
0 The index at which to start running the calculation order. -
fieldChanged(field)
-
Listener for field value changes.
Parameters:
Name Type Description field
Annotations.Forms.Field The field whose value changed. -
forEachField(callback)
-
Calls the specified callback for each of the root fields in the document. If there is a tree of form fields, then this will only iterate over root fields. Please use Annotations.Forms.Field.children and a tree traversal algorithm to traverse the fields. If you know the name of your field, you can use Annotations.Forms.FieldManager.getField.
Parameters:
Name Type Description callback
function The function that will be called for each field. The callback is passed the field object. Example
const stack = []; fieldManager.forEachField(function(field) { stack.push(field); // Push root fields }); while (stack.length > 0) { const current = stack.pop(); if (current.isTerminal()) { // Work with terminal/leaf fields } else { // Traverse children stack = stack.concat(current.children); } }
-
getCalculationOrder()
-
Gets the calculation order. @see Annotations.Forms.FieldManager.setCalculationOrder
Returns:
An array of field names.- Type
- Array.<string>
-
getField(name)
-
Gets a field whose full name matches the one that is given. If No field matches, and the last part of the field name is a number, returns that index of the field's widget array.
Parameters:
Name Type Description name
string The full name of the field to search for. Returns:
The field or widget, or null if no field matches. -
setAlertHandler(handler)
-
Updates the function to be used for handling alert messages for field validation.
Parameters:
Name Type Description handler
function The function that will handle alert messages. It will be called with a string representing the alert message. -
setCalculationOrder(order)
-
Set the calculation order - use this if you need changes in one field to trigger calculation events on other fields. If the name of field that is changed is before the name of another field, that other field is recalculated. If the name of the field that has changed is not in the array, all the fields named by the arrya are recalculated in order.
Parameters:
Name Type Description order
Array.<string> An array of field names. -
setPrintHandler()
-
Sets the function to be used to handle the print API called by embedded PDF JavaScript
-
updateFieldName(field, name)
-
Renames the field that is passed to the name passed in.
Parameters:
Name Type Description field
Annotations.Forms.Field | object The field that should be renamed. name
string The name of the field to be renamed. Cannot be blank. Returns:
The renamed field.