Field scripting in eDocBuilder allows you to apply unique styles to your document that may not be available with the conventional formatting tools. In the example shown, several fields have been combined within the contact information field. This concatenation permits the exclusion of information that is not applicable, or applying different formatting styles within the same field. More importantly, scripting provides the option of building a more intuitive interface for your customer.
In the example above, the contact information (Address, Telephone, Fax and email) were originally entered into one text field. This did not allow for flexibility of providing the address in a drop down, or ensuring that the customer used specific formatting (notice the periods between the digits in the phone and fax field), or kept the look of the card consistent with corporate policies. With field scripting we can create a separate form field for each of the different items that are included in that contact block and set very specific rules for each.
Instead of one field called "ContactInfo", the eDoc user interface for this business card now has additional fields added.
These fields will be concatenated using a simple script, and then displayed in the contact information field (ContactInfo).
The following steps will illustrate how a field script can be used to expand the capabilities of the user interface, and provide better service to your customer.
The first step in construction of this card is the addition of five new fields in the master PDF. The fields will be added to the original template in Acrobat Pro, using the Forms tool. These fields will not display on the final PDF, and their position is not critical.
The six new fields that have been added use a naming convention to distinguish them during the development process. The prefix "PH" indicates that these fields are "Place Holder" fields, used for data input but not displayed on the PDF. (PHAddress, PHPhone, PHEmail, etc.)
The practice of using a naming convention of this type can reduce much of the guesswork in future revisions to the document.
Upload the revised PDF with the new fields in place, then advance by clicking the Field Setup text button in the upper portion of the screen. Click the "Commit Changes" button at the top of the Field Setup tab.
The field setup automatically displays the five new fields within its list. Drag the fields into the order you would like them to be presented to the end user – ContactInfo, as a scripted field, will not be presented to the user in the input area. It will appear in the preview area combining all of the elements of the field script (our PH fields).
Expand the PHAddress Field by clicking the downward facing arrow at the end of the field. Click on the Field Type tab. Define the field type as “Text” coming from “User Entry”. Use these selections for all of the new fields that we will be creating.
In our example, we want the address to come from a drop down field so the customer can just choose their office without having to type in the information. To do this, on the Data Capture tab, User Control Type should be set for Drop Down List.
The user must select an address, so the Required check box is active. Note the address selections in the List Options field. As in the previous sample, a pipe character separates the city label, and hard returns are applied with a backslash and n or “\n”.
On the Format tab, the Field Usage setting (at the bottom of the screen) will be set to “Hide Field” for this field and the others being used in our field script. The other settings on this tab are not important. We want to hide the form field from being seen by the customer on the template because it will be part of the field script which is part of the ContactInfo field we will be using. Always remember to click the Save button after applying field settings.
For both the PHPhone and PHFax fields, these will be set to be text coming from user entry on the "Field Type" tab.
On the "Data Capture" tab, set the "User Control Type" to "Text Box."
On the "Format" tab select the "Text Reformat" drop down selector and pick the format style that you prefer for telephone numbers.
Again, Field Usage (at the bottom of the screen) will be set to “Hide Field”.
Click the Save tab to save your work after each field.
The PHEmail field should be set as text coming from user entry on the "Field Type" tab.
On the "Data Capture" tab, set the "User Control Type" to "Text Box."
A default field value may be entered. The advantage of this example, providing the @ symbol and a specific domain name, is that it lets the user enter their name before the default.
On the "Format" tab, Field Usage (at the bottom of the screen) will be set to “Hide Field”. Set the Text Reformat dropdown to Email.
Click the Save button when you have completed your entry.
Expand the“PHTelephoneExt”. Again, on the "Field Type" tab set the field to "Text" and "User Entry". On the "Data Capture" tab set the "User Control Type" to "Text Box." Set the prompt text under the Data Capture tab. The field usage on the "Format tab" should specify Hide Field.
The next step will be to expand the ContactInfo field. The five place holder fields will now be combined, using HTML language, within this field.
Under the Field Type for ContactInfo, specify "Text" and "Static Text or Field Scripting" for the data source.
The Data Capture tab is not required for the ContactInfo field because of the scripting that we will be using to capture the information.
Open the Format tab, specify your font preferences. The font preferences you set here will override any font preferences set on the "Format" tabs of the individual place holder fields. In this example field usage is set for both proof and production files.
When you first click on the Field Scripting tab, three selections will appear with radio buttons. The first selection is the default, None. The other two are HTML Markup and VB Script.
Select the HTML Markup radio button. The screen will expand to display the HTML text editor.
(Note that this editor is not WYSIWYG. If you wish to have format changes here, you must type HTML tags like <B> or <font>. See “HTML Field Scripting Reference – Syntax” for reference.)
* Be careful not to use empty tags in your html script otherwise you will get unexpected behavior.
On the right side of the toolbar is a field picker (dropdown). The information being used in our ContactInfo field will be brought in from the fields selected.
The illustration displays the fields surrounded on both ends by the @ character which is automatically placed before and after the field. This is the markup language that pulls the data from each of the fields.
Note the static text labels Phone, Cell, and Fax are typed into the appropriate position.
Double curly brackets have been added, surrounding the field names and labels of fields that may not be used. By doing this, the field and its label will not print on the document if no data has been entered into the field.
The hard line returns (created by hitting "Enter" on your keyboard) have been removed and replaced with the HTML code for a line break "<br/>". (The line break can be added using the "Insert Code Snippet" dropdown.) Activate the check box “Suppress Blank Lines”. This will insure that no blank lines appear within the block of copy. If the customer does not want the fax number to display, you don't want a blank space between the phone and email.
Click the Save tab to save your settings. You also must click the "Commit Changes" button at the top of the page.
If you need to use a VB Script you can start in HTML Markup and use the "Convert to VB" button at the bottom of the field to automatically change the HTML into VB Script.
| When more complicated formatting of the combined field area is necessary, scripting can get rather intricate. See the reference section for more details and examples.