Assign callback functions to the following fields of the mergeContext top‑level object at the end of the main()
function (or, when using exception handling, at the end of the try block within the function):
mergeContext field to which the
callback function is assigned
Stage of forms merge at which the
assigned function is called
Parameters of assigned callback
function
mergeContext.renderDataPage
After each page of input data is read
page—DataPage object containing the
data from the page
mergeContext.endDoc
After input from a single form is
completed and the resulting PDF is
rendered
fileName—String containing the
path and file name of the output PDF
mergeContext.endDataSet
After input from a single form is
completed and the resulting dataset is
generated
Note: A dataset is generated only if
this callback function is defined.
fileName—String containing the
path and file name of the dataset, which
can be sent to a printer with a forms
card
mergeContext.endData
After all input data is read None
mergeContext.endJob
After all PDFs included in the job have
been rendered
files—Array of strings containing the
file names of all output PDFs
A forms merge script with all callback functions defined is structured as follows:
function main()
{
try
{
//Actions to take when job is first submitted
…
//Assignment of callback functions
mergeContext.renderDataPage = myRenderDataPageFunction;
mergeContext.endDoc = myEndDocFunction;
mergeContext.endDataSet = myEndDataSetFunction;
mergeContext.endData = myEndDataFunction;
mergeContext.endJob = myEndJobFunction;
}
catch(e)
{
//Logging and other exception handling
…
throw e;
}
}
function myRenderDataPageFunction(page)
{
try
{
//Actions to take after each page of data
//is read from the input data
…
}
catch(e)
{
//Logging and other exception handling
…
throw e;
}
Developing workflow solutions 30