|
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). For each page in the PDF, a page will be added to the section. For information about Control Scripts in general, see Control Scripts and Control Script API. If you don't know how to write scripts, see Writing your own scripts. Cloning a sectionTo clone a section, first use the
Cloned sections have the same properties as normal sections, but they cannot call Calling
clone() multiple times before calling addAfter() or addBefore() currently won't work, as each next clone will get the same default name and replaces the previous clone. To avoid this you should either explicitly assign a unique name to each clone (i.e. not rely on the default name), or call addAfter() or addBefore() before calling clone() again.Renaming a cloneBy default, clones receive the name of their source section with a "Clone {sequence}" suffix, for example: Use the
To ensure that CSS rules 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). Targeting elements in a cloned sectionClones that have a unique name can be further personalized with the use of CSS style sheets (see Styling and formatting) and personalization scripts (see Variable Data and Writing your own scripts). The following CSS style rules target the <h1> element in a number of clones and assign the respective text a different color:
The same selector could be used in personalization scripts: Selector: Inside a template script, cloned sections can be found using
Note that in a Control Script, ExamplesCloning a section based on the number of records in a detail tableThis script creates as many clones of a section as there are records in a detail table. It assigns the new sections a unique name.
Cloning a section based on data and assigning a background PDFThis script clones a section based on data fields. It disables the source section first and then calls the
|
|