OL Learn

Can a section be made to not print if the background image is not found?

Hello,

From a control script, I’m sure this is possible, but is there some setting or check box that will also do this in Connect Designer for a section that uses a dynamic image?

Feature request if not :slight_smile:

thanks!

Lou Pace

1 Like

Use the resource() method in your control script to check for the existence of the dynamic images and then enable the relevant sections and apply their corresponding background images (no checkbox currently exists for this):

let section = merge.template.contexts.PRINT.sections['Section 1'];
let currentBackgroundImage = record.fields.imagesPath + record.fields.backgroundImg; //Ex: c:/images/test.jpg
section.enabled = false;

if (!section) {
  throw "'Section 1' not found";
}
if (resource(currentBackgroundImage)) {
  section.enabled = true;
  section.background.source = BackgroundResource.RESOURCE_PDF;
  section.background.url = 'file:///' + currentBackgroundImage.replace(/\s/g, '%20');
}

Rod, if my template has a div that uses a background image instead of the section, can I still do the same and raise an error/ not print the section?

end user wants a notification if their document is missing an image.