Stefan Cameron on Forms
Building intelligent forms using Adobe LiveCycle Designer

'Scripting' Category Archive

Adobe LiveCycle ES Update 1 Documentation

Since the release of Designer ES 8.2 and now LiveCycle ES Update 1, the documentation page has been updated with all sorts of goodies related to Update 1, including the following Designer-related documentation:

  • Scripting Reference (technical document about scripting your forms)
  • Target Version Reference (if you want to know what features are compatible with specific PDF versions or if you’re using Designer ES 8.2 to build a form for users on Acrobat/Reader 7.x and you want to make sure they can use your form)
  • Scripting Errors Reference (solutions to common scripting errors)
  • FormCalc Reference (for those of you who like to use FormCalc instead of JavaScript, this reference includes previously-omitted information about various language constructs such as “while”, “for” and “for each” loops)

Posted by Stefan Cameron on July 21st, 2008
Filed under Designer,FormCalc,Scripting

Auto-splitting text between two text fields

The scenario

You have a compliant form that has sections for users to fill-in information. Because the form is compliant (i.e. its layout has received the “stamp of approval” and cannot change without another lengthy approval process), the sections cannot grow (they cannot expand-to-fit all of the text users may fill-in). To provide more space for users to add more text, you’ve provided an expandable “overflow” section at the end of form since expanding that section will not affect the portion of the form which has been approved.

The problem

You need to capture the text entered into the form using an interactive Form Guide which is not limited to the restrictions of the form’s approved layout. As such, the Form Guide will capture the text in a single field and you need that text to be entered into the PDF version of the form. If you put all the text into the appropriate section on the form, it won’t fit and the text will be cut-off (e.g. it will not print entirely and you will miss some of the important information).

You need some way to automatically split that text between the small section in the form and the overflow section at the end of the form. In other words, you need to ensure that only the text that can fit within the small form section is placed there and the rest is placed in the overflow section at the end.

In Designer 8.2, the content of fields can now be split between pages however in this case, you can’t use this feature because the small form section can’t be expanded (it’s fixed in size).

The solution

This is the problem Stephanie, Glenn and I were faced with on a recent customer visit. Stephanie took the time to put this into a sample form which provides the script we wrote to handle this task. It’s basically a mini text parser written in JavaScript that splits text between two fields with a fixed-width font (e.g. Courier New, Lucida Console, etc.).


Posted by Stefan Cameron on July 10th, 2008
Filed under Acrobat,Designer,Form Guides,Scripting,Tutorials

Form Object Order of Initialization

Here’s a quick observation you might find useful: The order in which form objects are initialized is “field and depth-first” according to the document order (the top-down order in which they appear in the Hierarchy palette in LiveCycle Designer). This means that fields inside a subform are initialized before the subform itself is initialized. When you think about it, it makes sense since this means that in a subform’s Initialize event, you always have access to properly-initialized child form objects. You can read more about event execution order in the LiveCycle Designer Scripting Basics document (page 24) as well as in the

XFA Spec (page 353 in version 2.7).

Say your form object hierarchy looked like this (in the Hierarchy palette in Designer):

Hierarchy Order

The fields and subforms would get initialized in the following order:

Order of Initialization

To clarify, this is the order (note that text objects don’t get initialized just like squares, circles and images wouldn’t — image fields would, however):

  1. DateTimeField1
  2. TextField1
  3. PasswordField1
  4. Subform2
  5. NumericField1
  6. Subform1
  7. CheckBox1

To demonstrate this, I’ve provided the form that contains the objects above. When you preview the form (or view it in your web browser) using Acrobat, use the JavaScript Console to see the output from the Initialize events of the various form objects to see the order of initialization.

Download Sample [pdf]

Minimum Requirements: I created this form in Designer 8.1.1 SP2 and tested it in Acrobat Pro 8.1.2.


Posted by Stefan Cameron on May 9th, 2008
Filed under Events,Scripting,Tutorials

Field Background Color Fill

Did you know that you can quickly set the background fill color of a field via script using the

fillColor

property? This can be very handy if you want to highlight a field for some reason. The property takes an RGB color value as a string: "255,0,0" would give a red fill.

What you may not realize is that fields actually have two areas: The "nominal extent" represents the entire field, including the caption, while the "content extent" represents only the data input portion of the field. There’s a difference between setting the fill color of one vs. the other.

The Nominal Extent Fill

When you set the fill color using the "fillColor" property, you’re setting the fill color of the nominal extent’s border property. It’s actually a shortcut:

TextField1.fillColor = "255,255,0"; // yellow

is equivalent to this:

TextField1.border.fill.color.value = "255,255,0";

Here’s a text field with no fill:

And here it is after setting its "fillColor" property to yellow:

(On a side note, you may notice that the field now has a border and you’re probably wondering where it came from. See this article for an explanation and what you need to do to get rid of it.)

The Content Extent Fill

So how do we set the fill color of the content extent without filling the entire field? The content extent’s fill color is specified within the field’s content extent (or "UI", in XFA terms) border and is accessed like this:

TextField1.ui.oneOfChild.border.fill.color.value = "0,200,0"; // green

(If you’re wondering what the "oneOfChild" property is, see this article.)

The result of the above line of script on the initial text field is as follows:

For example, you could use the content extent fill color as a way to communicate to someone that a field is disabled (by setting its content extent fill color to light gray (230,230,230)).

Finally, you can combine the two as follows (this being the combination of setting both the nominal and content extent fill colors):


Posted by Stefan Cameron on March 14th, 2008
Filed under Scripting,Tutorials

Book now available: Creating Dynamic Forms with Adobe LiveCycle Designer

That’s right: The day has finally come! Designer officially has its very first book on the market, thanks to J.P. Terry at SmartDoc Technologies.

The book is the result of J.P.’s own expertise and a collaborative effort with the Designer Team in Ottawa. It tackles form design and techniques in building dynamic XML-based PDF forms with Designer.

As Alan Siegel (Founder & Chairman of Siegel+Gale, branding pioneer and champion of simplifying corporate communications) put it,

“J.P. Terry is a rare individual who understands both the design and technical issues involved with effective communications. This book will teach you about LiveCycle Designer but more importantly it will teach you about effective form design.”

How to get the book

The book is now available for immediate ordering at the following sites

as well as at various local bookstores.

For some reason, it’s still on “pre-order” status at Amazon.com but should be “officially” available shortly.

The Designer book will also be available for purchase at MAX 2007 and I will be giving away a copy or two at my hands-on sessions on Designing PDF Forms and Flex-based Form Guides so be sure to attend if you’re at MAX 2007 North America!

Sample Files Posted

For those of you who already have the book, you can now download the sample files from SmartDocTech.com.


Posted by Stefan Cameron on August 30th, 2007
Filed under Books,Designer,Instance Manager,Scripting,Tables,Tutorials