Dynamic image in Designer as overlay on media

Hi

Have to put an overlay on a media in Designer

Tried to put the dynamic overlay on the print with the following script:

var printSections = merge.template.contexts.PRINT.sections;
var resourceUrl = record.fields.Overlay;
printSections[‘Overlay’].background.source = BackgroundResource.RESOURCE_PDF;
printSections[‘Overlay’].background.url = resourceUrl;

record.fileds.Overlay holds the path and filename for the overlay pdf file like c:\Temp\Overlay.pdf

Problem is, that the overlay is placed in front of the letter and is not transparent – so the merge in the script is not an option.

If the same overlay pdf file is placed as a background (static image) on a media it is working 100% and is tranparent.

Is there a way to put the dynamic overlay on the media instead with a script?

It works if you put it in the Virtual Stationary?

If that’s the case, you can access the Virtual Stationary programatically, just like you’re doing with the print section’s background.

merge.template.media[“Media 1”].stationery

If I put the static overlay PDF file on a Media an control the different medias with a media script, the overlay is printed correct with tranparency.

But can’t figure out how to make a script where the pdf file used for the overlay is dynamic from the datamapper.

Thsi script only set the background on the print content page

var resourceUrl = record.fields.Overlay;
printSections[‘Overlay’].background.source = BackgroundResource.RESOURCE_PDF;
printSections[‘Overlay’].background.url = resourceUrl;

Well, like I said, you need to access the Media, not the Print Section.

merge.template.media[“Media 1”].stationery.front.enabled = true;
var honorific = record.fields.Honorific;

if(honorific == ‘Mr’){
merge.template.media[“Media 1”].stationery.front.url = “images/BACK-M-LT.pdf”;
}else{
merge.template.media[“Media 1”].stationery.front.url = “images/BACK-F-LT.pdf”;
}

Above is a simplified example that has different backgrounds depending on the recipient’s honorific. If the path to your images is in the data, just substitute my image calls for your variable path.