2022.2

Table Of Contents
ground(see"ControlScript:SettingaPrintsection'sbackground"onpage845).Foreachpageinthe
PDF,apagewillbeaddedtothesection.
ForinformationaboutControlScriptsingeneral,see"ControlScripts"onpage838and"ControlScript
API"onpage1271.Ifyoudon'tknowhowtowritescripts,see"Writingyourownscripts"onpage808.
Note: Clonesareonlyvisibleintheoutput,notonthePreviewtab.
Cloning a section
Tocloneasection,firstusetheclone()functionandthenaddtheclonetothePrintcontextbeforeor
afteraspecificsection,usingaddAfter()oraddBefore():
var printSections = merge.template.contexts.PRINT.sections;
var clone = printSections["Section 1"].clone();
printSections["Section 1"].addAfter(clone);
Clonedsectionshavethesamepropertiesasnormalsections(see"section"onpage1305),butthey
cannotcallthesectionfunctionsclone(),addBefore()andaddAfter(),whichmeansyoucannot
cloneaclone,oruseacloneasastartingpointtoinsertotherclonesintoatemplate.
Notethatwithmultipleclones,thenextcloneisalwaysaddedafterthepreviousclone.
WithaddBefore(),thecodeoriginal.addBefore(clone1); original.addBefore
(clone2);willresultin"clone1,clone2,original".
WithaddAfter()thecodeoriginal.addAfter(clone1); original.addAfter(clone2);
resultsin"original,clone1,clone2".
Renaming a clone
Bydefault,clonesreceivethenameoftheirsourcesectionwitha"Clone{uniqueidentifier}"suffix,for
example:
Source:"Section1"
CloneName:"Section1Clone71c3e414-fdf3-11e8-8eb2-f2801f1b9fd1"
Usethenamepropertytoassignanothernametotheclonedsection,forexample:
clone.name = "my_section_clone";
Justlikesectionnames,theclone'snameshouldbeunique-withinthescopeofasinglerecord,thatis;
acrossrecords,thesamenamecanbeused.
Whentwoclonesgetthesamenameinthesamerecord,oneoftheclonesmaynolongerbeused.This
ispreventedbygivingclonesuniquenames.UniquenamesalsoensurethatCSSrulesandscriptscan
targetaspecificclone.
Page 847