|
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 Due to resource constraints, the number of unique clones that can be created throughout a job is limited to around 20. A clone is considered unique if it has a different name. This is a rough estimate; if the template is simple, up to 60 clones may be created.
The limit only applies to the amount of unique clones. There is no limit to the amount of clone() function calls.Renaming a cloneBy default, clones receive the name of their source section with a "Clone {sequence}" suffix, for example: Use the
The section name must be unique within the scope of a single record. It is recommended not to use a random value or a time stamp in the name of a section. Although section names must be unique within the scope of a record, across records it is advisable to keep using the same name for the same clone, to avoid hitting the limit of the number of unique clones that can be created throughout a job (see the previous note).
Targeting elements in a cloned sectionAs each clone receives a unique section name, one could use CSS style sheets (see Styling and formatting) and personalization scripts (see Variable Data and Writing your own scripts) to further personalize the cloned sections. The following CSS style rules target the <h1> element in a number of clones and assigns the respective text a different color:
The same selectors could be used in personalization scripts: Selector: In 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
|
|