2022.2

Table Of Contents
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);
}
ControlScript:SecuringPDFattachments
ThePrintcontextcanbeattachedtoanemailintheformofaPDFfileandsecuredwithapassword.
ThiscanbedonewithoutaControlScript,see"Emailattachments"onpage489and"EmailPDFpass-
word"onpage488.
WithaControlScript,youcandothesame,andmore:theattachmentcanbesplitintomultipleattach-
ments(seeParts).Eachattachmentmayhaveadifferent(orno)setofpasswords,soyoucouldmix
securedandunsecuredattachmentsinasingleemail.Thistopicshowshow.
ForinformationaboutControlScriptsingeneral,see"ControlScripts"onpage838and"ControlScript
API"onpage1271.Ifyoudon'tknowhowtowritescripts,see"Writingyourownscripts"onpage808.
Settingpasswordsinscript
TosetapasswordonaPrintsectioninaControlScript,thescriptshouldfirstretrievethePrintsec-
tion/susingmerge.template.contexts.PRINT.sectionsormerge.context.sections(also
seetheexamplebelow).
Next,thescriptcansplittheattachments,ifneeded(see"Parts:splittingandrenamingemailattach-
ments"onpage843),anditcansetapasswordoneachsection.Forexample:
l
merge.template.contexts.PRINT.sections['Section 2'].password =
'secret';
l
merge.template.contexts.PRINT.sections['Section 2'].ownerPassword =
'secret';
Whenproducingasingleattachment,thepassword(s)shouldbesetonthefirstPrintsection.
Whenproducingmultipleattachments,itshouldbesetonthefirstsectionofeachpart.
Password types
PDFallowsfortwotypesofpasswordstobesetonasecuredPDFfile:auserpasswordandowner
password.Theuserpasswordallowsalimitedaccesstothefile(e.g.printingorcopyingtextfromthe
PDFisnotallowed).Theownerpasswordallowsnormalaccesstothefile.TheEmailPDFpassword
Page 849