Applying formatting by using client-side scripts

In a static PDF form, only the value area of the field can be updated on the client. Everything else on the form is frozen or fixed. In a dynamic PDF form, the entire field object can be updated on the client. The examples that follow are provided to give you an idea of what happens.

Changing the field border color

If you create a client-side script to apply borders to objects, the results differ in static and dynamic PDF forms.

For example, you can write a script on the exit event of a field to turn the border color red:

TextField1.border.edge.color.value="255,0,0"

In a static PDF form, the outline of only the value area turns red after the end user exits the field.

In a dynamic PDF form, the outline of the entire field object turns red after the end user exits the field.

Applying field shading

If you create a client-side script to apply shading to objects, the results differ in static and dynamic PDF forms.

For example, you can write a script on the exit event of a field to turn the shading color in the field to red:

TextField1.fillColor = "255,0,0"

In a static PDF form, only the value area turns red after the end user exits the field.

In a dynamic PDF form, the entire object, including the value area, turns red after the end user exits the field.

Hiding objects

If you create a client-side script to hide objects, the results differ in static and dynamic PDF forms.

When you are designing a static or dynamic PDF form, you can hide objects on the form by setting the presence property to either “invisible” or ”hidden”. In both cases, the objects do not appear in the final output; however, when you set the presence value to “hidden”, objects do not occupy any space in the layout. If the objects are inside flowed subform objects, the subform itself will shrink in response to the hidden objects.

The difference between static and dynamic PDF forms is that on a static PDF form you cannot change the presence value of an object by using an interactive scripting event, such as the click event of a button. Static PDF forms cannot rerender on the client; therefore, scripts executed on interactive events cannot change the visibility of form objects. Dynamic PDF forms do not have the same limitation because they can rerender on the client.

You can change the visibility of form objects on static PDF forms by using non-interactive events that trigger during form rendering, such as the initialize event. For example, on a dynamic PDF form, you can write a script on the click event of a button to hide a text field:

TextField1.presence = "invisible"

Alternatively, you can use this script to completely remove the text field from the layout:

TextField1.presence = "hidden"

In both cases, to achieve the same results on a static PDF form, you use the same scripts but write them on the initialize event of either the text field or the button.

// Ethnio survey code removed