2018.1

Table Of Contents
Dynamically adding sections (cloning)
This topic explains how to clone a section in a Control Script. Print sections can be cloned, so
that a document can have a dynamic number of sections, based on data. This is particularly
useful when the record set defines one or more PDFs (e.g. insurance policies) per recipient.
Via a Control Script, for each PDF a section can be cloned and each clone can be given one of
the PDFs as background (see "Control Script: Setting a Print section's background" on
page719). For each page in the PDF, a page will be added to the section.
For information about Control Scripts in general, see "Control Scripts" on page711 and
"Control Script API" on page1077. If you don't know how to write scripts, see "Writing your own
scripts" on page689.
Cloning a section
To clone a section, first use the clone() function and then add the clone to the Print context
before or after a specific section, using addAfter() or addBefore():
var printSections = merge.template.contexts.PRINT.sections;
var clone = printSections["Section 1"].clone();
printSections["Section 1"].addAfter(clone);
Cloned sections have the same properties as normal sections, but they cannot call section
functions.
Renaming a clone
By default, clones receive the name of their source section with a "Clone {sequence}" suffix, for
example:
Source: "Section 1"
Clone Name: "Section 1 Clone 1"
Use the name property to assign the cloned section another name, for example:
clone.name = "my_section_clone";
To ensure that CSSrules and scripts can target a specific clone, that clone's name should be
unique (within the scope of a single record, that is; across records, the same name can be
used).
Page 721