It's designed for a single independent checkbox. The following script makes one or more fields visible when the checkbox is checked and hides them when it is unchecked. This is not a value based property, so it is not ideal but will work in most cases. The only event that is readily useful for a checkbox is the MouseUp. Setting Field Visibility Based on a Checkbox An example of this is provided in the Validation Message section below. If popup visibility requires more complex conditions, then scripting is required. In this case, the OnFocus is used to hide the field when the user clicks into the text field. Use the MouseEnter event to make the popup message field visible, then use both the MouseExit and OnFocus to hide it (shown in the screen shot). The exact same technique works for any field type and scripting is not needed. The idea is to display a graphic or message when the cursor rolls over a particular form field. One scenario where field visibility is not dependent on a field value is the rollover popup. Rollover Popup Message Setup Using Visibility for a Rollover (or other type) Popup Message/Graphic For example, if a field is named "PhoneNumber", and there are 3 instances of this field on the form, then the widgets are named PhoneNumber.0, PhoneNumber.1, and PhoneNumber.2. Field widgets have their own special naming convention, so individual widget visibility is set using the special widget name. When the regular field name is used with getField(), the resulting field object sets the visibility for all of the Widgets. So the visibility for each instance, or widget, can be set separately. While widgets share the same value properties, they have different appearance properties, including visibility. If two fields have the same name, they are essentially the same field as far as all the value properties are concerned, but what about visibility? Each instance of a field with the same name is called a Widget. This.getField("MyField").display = display.visible This.getField("MyField").display = display.hidden Display constantsĪcrobat provides a set of built-in constants in the display object so you don't have to remember which integer value corresponds to which field display option. Do not use them, they are only provided here for completeness. These properties are intended to be used only for scripts that will be viewed in the version of Acrobat preceding deprecation, which happens to be version 3.0. However, lots of documents had already been created using these properties so they left them in the DOM until such time they feel it's ok to remove them in a future version. This means that Adobe re-thought how they had set up these properties and decided to change it. 3 Field Hidden in Viewer, Visible on Printed DocumentĪs noted in the table, the first two properties are deprecated.2 Field Visible in Viewer, Hidden on Printed Document.1 Field Hidden in Viewer and in Printed Document.0 Field Visible in Viewer and Printed Document.Integer Value Replaced hidden and print in Acrobat version 4.0 true Field Displayed in Printed Document.The Acrobat JavaScript DOM provides three different Field Object properties for controlling these options, listed in the table below.ĭeprecated Property May be removed in future versions of Acrobat This OCG layer method will not be covered in this article.Ī form field on a PDF document can be visible in the PDF viewer (i.e., Acrobat, Reader), on the printed document, or both. In fact, layers can even be attached to form fields, so the visibility of a group of fields and related graphics can be shown and hidden with a single line of code. So, another way to show/hide text and graphics is with OCG layers. Both the annotation and the fields are shown and hidden together to highlight extra information the user needs to fill in.Īnnotations are adequate for simple graphic and text, but can become unwieldy for more complex layouts. In the example file linked below, one of the examples uses a Rectangle annotation as the background for a group of fields. All commenting and markup annotations can also be shown and hidden. Graphics that need to be shown and hidden can usually be added as markup annotations (line, stamp, etc). An easy way to hide/show a label is to make a read only text field or a text markup annotation. In most situations there are also text and graphics associated with the fields. In most cases it's not enough to simply control field visibility. Another good use is displaying messages to the user. A couple common scenarios are to keep the user focused on only those parts of the form they need to fill out, and to keep them from being confused by unnecessary fields. There are many scenarios where it is desirable to show and hide form fields on a PDF.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |