On this Page

    Merge Scripting

    Several of the DocOrigin components (Merge, Control, QueueProcessor etc.) use a common set of JavaScript (Mozilla ECMA 262) conventions and extensions. See section Scripting for a complete list of script functions and DOM access.

    Suggested Scripting Guidelines

    1. Whenever possible, scripting should be completed prior to the Pagination event.
      For most applications, the Data Merged event is the most suitable for scripting; at this point, Merge has combined the form and data and performed the word-wrapping, but overflow pages have not yet been established. If a script changes field data after the Pagination event, the field will be re-word-wrapped, but the results cannot affect pagination. For a description of the Merge events, see Merge Events.
    2. To simplify object naming and to avoid complications with dynamic tables and panes, the best approach is to associate script with the object it is modifying, or with a "parallel" sibling object or a near parent object.
    3. When using the _document DOM to access form objects, ensure that the referenced objects have unique names.
    4. When Merge splits a table row or a pane between two pages, not all form objects in the Row or Pane may appear on both pages. Fields and text below the split will appear on only the second page; those objects above the split will appear on only the first page. Script on the row-that-references-these-objects will fail in circumstances where Merge has moved the referenced objects. This issue may be resolved in DocOrigin Design by associating script with the form objects.
    5. In Design, any table row or pane may be flagged as "Allow Multiple". Within a script, the pane or table row will be treated as an array object, which must be referenced as Row[2] of Pane1[0]. Even when only one instance of that table row or pane is created, the reference must use a [0] index.

    In DocOrigin Design, use the PDF Preview or Merge Test command on the Tools menu to assist in debugging scripts in the form. The commands use Merge to combine the form with test data, and to display the result on-screen or print the output, respectively. For the test data:

    1. Click Auto-generate test data, and click Save Data, to create a compatible starting data file. Then edit the data file to test specific conditions that might be encountered.
    2. Click Use my test data to provide a test data file created from an application or from an edited auto-generated file.
    3. Include Common Merge Command Line Options which will cause each Merge test run to create a trace file -trace tracefile.txt
    4. After each test run, review the content of the trace file using a text editor.
    5. REPEAT: After each test run, review the content of the trace file using a text editor.