2022.2

Table Of Contents
CloningasectionbasedondataandassignabackgroundPDF
Thisscriptclonesasectionbasedondatafields.Itdisablesthesourcesectionfirstandthencallsthe
addPolicy()function.addPolicy()clonesthesection,renamesitandsetsaPDFfromthe
resourcesasitsbackground.ItexplicitlyenablesthecloneandthenaddsittothePrint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marginsobjectisusedtosetaPrintsectionorMasterPage'smarginsinaControlScript(see
"ControlScripts"onpage398and"ControlScriptAPI"onpage815).
NotethatMasterPagesareonlyusedinaPrintcontext(see"MasterPages"onpage141).
Themarginsobjectisretrievedviathesectionobject(see"section"onpage848)orviathemas-
terpagesarrayinatemplate(see"masterpage"onpage817),respectively.
Fields
Field Type Description
bottom
left
right
top
String Thesefieldsallowtosetthebottom,left,rightandtopofaPrintsection,usingaMeasurementstring,for
example:"2in"(thissetsamargintotwoinches).
footer
header
String ThesefieldsallowtosettheheaderandfooterofaMasterPage,usingaMeasurementstring.
Examples
Setting the margins of a Print section
var sectionA = merge.template.contexts.PRINT.sections["Section A"];
sectionA.margins.top = "2in";
sectionA.margins.left = "2in";
sectionA.margins.right = "2in";
sectionA.margins.bottom = "2in";
Page 853