2021.2

Table Of Contents
Cloning a section based on data and assign a background PDF
This script clones a section based on data fields. It disables the source section first and then
calls the addPolicy() function. addPolicy()clones the section, renames it and sets a PDF from
the resources as its background. It explicitly enables the clone and then adds it to the Print
context.
var printSections = merge.template.contexts.PRINT.sections;
merge.template.contexts.PRINT.sections["Policy"].enabled = false;
if(record.fields.policy_a == 1) {
addPolicy('a');
}
if(record.fields.policy_b == 1) {
addPolicy('b');
}
function addPolicy(policy){
var resourceUrl = 'images/policy-' + policy + '.pdf';
var clone = printSections["Policy"].clone();
clone.name = "policy_" + policy;
clone.background.url = resourceUrl;
clone.enabled = true;
printSections["Policy"].addAfter(clone);
}
margins
The margins object is used to set a Print section or Master Page's margins in a Control Script
(see "Control Scripts" on page913 and "Control Script API" on page1405).
Note that Master Pages are only used in a Print context (see "Master Pages" on page506).
The margins object is retrieved via the section object (see "section" on page1454) or via the
masterpages array in a template (see "masterpage" on page1409), respectively.
Fields
Field Type Description
bottom
left
right
top
String
These fields allow to set the bottom, left, right and top of a Print
section, using a Measurement string, for example: "2in" (this sets
a margin to two inches).
Page 1463