Remember the following tips when debugging calculations
and scripts.
Sample data
Remember to specify a preview data file in the Form
Properties dialog box. Specifying a preview data file does not save
the data into the final PDF.
Master pages
To debug master pages, drop a different object on
each master page to find out which one is specified.
First page in a form
Designer looks at the root subform to determine
which page to begin the form on. If the root subform does not determine
the first page, the first master page is used by default.
Incremental debugging
When debugging a form design, start by removing
pieces of the form until you cannot reproduce the problem. Try to
isolate the source of the problem after you've reviewed every script
and object property. To debug subforms, you can specify a thick
colored border around the subform, or use a fill. Colors or fill
can help indicate which subform is used and its span. Usually, this
technique works well when you want to determine the bounds of an
object and can show why it is placed in a certain location.
Hierarchy view
View your form design by using the Hierarchy view
to get a better understand of it. The order of the objects that
are listed in the hierarchy indicates the order they are placed
on the page. Some objects are not clickable if they are below one another.
Script error messages
In Designer, script error messages appear
on the Log tab of the Report palette when you preview the form.
If the form design contains FormCalc scripts and the error occurs
on the server, the warnings appear in the Log tab. If the FormCalc script
error occurs on the client, the message appears in Adobe Reader
or Acrobat.
An error in a FormCalc script prevents the entire
script from executing.
An error in a JavaScript executes
until it reaches the error.
Syntax errors in FormCalc
Syntax errors in FormCalc are sometimes
difficult to solve. When the "Syntax error near token '%1' on line
%2, column %3" appears,
%1
usually contains the
token (word) nearest to the error. Therefore the token is possibly
correct and the error is not related to the error other than its
proximity to it. For example, the following script generates the
7008 error: "Syntax error near token 'then' on line x, column y."
var b = abc(1)
if (b ne 1) then
//comment
The problem is that an
endif
token
is missing from the script. The last correct token is
then
(comments
do not count as tokens). Adding an
endif
statement to
the end of the script fixes the problem.
Functions defined in a script object
You can only call a function
that is defined in a script object with a JavaScript script. Make
sure that you change the script language to JavaScript in the Script Editor.
If not, you may see a message indication that Designer cannot resolve
the script object. The same error can occur when a syntax issue
occurs in the script object.
Web service calls
When creating web service calls, use the
postExecute event to see what was returned and whether the web service
issued any error messages.
Long SOM expressions
When typing long, multilayered SOM expression,
press the Ctrl key and click the object on the canvas. The command
inserts the object's SOM expression into the script. The SOM expression
is relative to the object hosting the script. To insert the absolute
SOM, press Ctrl+Shift and click the object. These commands work when
you click objects in the Design view, not in the Hierarchy view.
Test SOM expressions
When a long SOM expression fails, start
back at the root of the expression and test each dot with
className
until
you reach the problem. For example, test
a.b.c.d
by
starting at the root:
-
console.println(
a.className
)
-
console.println(
a.b.className
)
-
console.println(
a.b.c.className
)
-
console.println(
a.b.c.d.className
)
Use script objects to debug form designs
Use a script object,
such as a fragment, to help you debug form designs:
-
Dump out a node hierarchy under a node.
-
Output the value of a property or attribute of a node.
-
Output whether a node has a property or attribute specified.
-
Output the SOM expression of a node.
-
Dump out the
xml src
of a given node.
Here
is an example of a script object that contains several debugging
functions:
<script contentType="application/x-javascript" name="XFADEBUG">
//This script object provides several tracing functions to help debug a form design
//Dump out node hierarchy to console.println()
function printNode(node) {... }
//Dump out SOM expression to console.println() function printSOM(node) {... }
//Dump out property or attribute value function printValue(node, attrOrPropertyName) {...}
function printXMLSource(node) { ....}
function printHasPropertySpecified(node, prop) {...}\\
</script>
Things to avoid when building forms
-
Calling
xfa.layout.relayout().
on
the
docReady even
causes problems because the
docReady
event
triggers every time the layout is ready.
-
Placing a flowed container inside a positioned container
causes problems with page breaks, overlapping objects, and repeating
subforms. The root subform is a flowed container. Take advantage
of it and place your flowable containers inside the root subform
by unwrapping the page subforms after your layout is done. Alternatively,
set the flow of the page subforms to flowed.
-
Blank page issue (Acrobat 7.1 or earlier). At design time,
a blank page is displayed when the subform does not fit within the
boundaries of the content area. To fix the blank page, either resize
the subform or allow it to break between pages. If a user is using
Acrobat 7.1 or earlier, the second-level subform appears on a different
page.