2022.2

Table Of Contents
activeSection.background.position = MediaPosition.FIT_TO_MEDIA;
Forallpossiblepositions,see"MediaPosition"onpage1296.
Setting a page range in script
WhenaPDFthatservesasadynamicsectionbackgroundhasmultiplepages,youcanspecifyarange
ofpagestobeused,inacontrolscript.
Putthenumberofthefirstpageintherangeinthesection'sbackground.startfieldandthelastpagein
background.end.
Thefollowingscriptsetsthepagerangefrom2to5:
merge.template.contexts.PRINT.sections['Policy'].background.start = 2;
merge.template.contexts.PRINT.sections['Policy'].background.end = 5;
Settingapagerangeautomaticallysetsbackground.allPagestofalse(see"background"on
page1286).
Ontheotherhand,whenyoufirstdefineapagerangeandthensetbackground.allPagestotrue,this
disablesthepagerange.
Tip: Youcouldusetheresource()functiontocheckthenumberofpagesorforexamplethe
pageheightandwidthbeforesettingitasabackground(see"resource()"onpage1278).
ThisscriptsetsabackgroundonaPrintsectionusingabsolutepositioning.
var activeSection = merge.template.contexts.PRINT.sections['Section 1'];
activeSection.background.source = BackgroundResource.RESOURCE_PDF;
activeSection.background.url = "images/somepage.pdf";
activeSection.background.position = MediaPosition.ABSOLUTE;
activeSection.background.left = "10mm";
activeSection.background.top = "10mm";
YoucouldreplacethelastthreelinesofthepreviousscriptbythefollowinglinetoscalethePrintsec-
tionbackgroundtoMediasize:
activeSection.background.position = MediaPosition.FIT_TO_MEDIA;
Dynamicallyaddingsections(cloning)
Thistopicexplainshowto"clone"(copy)asectioninaControlScript.Printsectionscanbecloned,so
thatadocumentcanhaveadynamicnumberofsections,basedondata.Thisisparticularlyuseful
whentherecordsetdefinesoneormorePDFs(e.g.insurancepolicies)perrecipient.ViaaControl
Script,foreachPDFasectioncanbeclonedandeachclonecanbegivenoneofthePDFsasback-
Page 846