Hi,
I am curious to know why most of my questions have been left unanswered? Perhaps They aren’t visible to the public?
Anyway, I have a control script where I am trying to set the media of my sections\masterpages dynamically, but they don’t work. I hope someone can help? Below is my control script. My sections backgrounds are the datamapper PDF:
var VSPathFirstSheet = “images/firstsheetpdf”;
var VSPathOtherSheets = “images/othersheets.pdf”;
// function that applies the media
function applyMedia(mediaName,enabled,face,path,page){
let media = merge.template.media[mediaName].stationery[face];
media.enabled = enabled;
media.url = path.replace(/\s/g,‘%20’);
media.page = page;
media.position = MediaPosition.CENTERED;
}
applyMedia(‘FirstSheet’,true, ‘front’, VSPathFirstSheet, 1);
var pagecount = record.fields.totalPages;
if(pagecount== 1){
applyMedia(‘FirstSheet’, false, ‘back’, VSPathFirstSheet, 2);
}else if(pagecount == 2){
applyMedia(‘FirstSheet’, true, ‘back’, VSPathFirstSheet, 2);
}else if(pagecount > 2 ){
applyMedia(‘OtherSheets’, true, ‘front’, VSPathOtherSheets, 2);
if(pagecount %2 == 0){
applyMedia(‘OtherSheets’, true, ‘back’, VSPathOtherSheets, 2);
}else{
applyMedia(‘OtherSheets’, false, ‘back’, VSPathOtherSheets, 2);
}
}