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);
}
background
ThebackgroundobjectholdsthePDFbackgroundofaPrintsection(see"section"onpage1305and
"ControlScript:SettingaPrintsection'sbackground"onpage845).
Note: Settingapagerangeusingthestartandendfieldsautomaticallysetsback-
ground.allPagestofalse.
Whenyoufirstdefineapagerangeandthensetbackground.allPagestotrue,thepage
rangewillbedisabled.
Fields
Field Type Description
allPages
Boolean ShowallpagesfromthePDF.
end
Number TheendpageofthePDFtouseasabackgroundforthesection.
left
Measurement TheleftoffsetofthePDFbackground(onlywhenabsolutepositioningisselected).
position
"MediaPosition"on
page1296
SetthepositionofthePDFbackground(Absolute,centered,fittomedia).
rotation
Number SettherotationofthePDFbackgroundto0,90,180or-90degrees.
Page 1286