Dynamic background multiple master pages

Hi,

Currently I have 2 master pages, front and back, and one Print section all the record details like name, record ids, address block are on the master page (front page) and some repeated details in the back (master page back).

This is set up this way because there will be an overflow happening on the first page body, when it does overflow front/page are repeated to the next sheet. This is fine and working.

I have set the background in the media, where I set front and back. This is working just fine.

But if I want to introduce dynamic background, how would my control script look like?
I am aware that I can do something like this:

var background = newClone.background;
background.source   = BackgroundResource.RESOURCE_IMAGE;
background.allPages = true;

if(jobName.toLowerCase().indexOf("another job") >=0){
	background.url  = "images/background for job 1.pdf"; // 2 pages pdf
} else {
	background.url 	= "images/background for job 2.pdf"; // 2 pages pdf
}

This does not work, as it gives me 4 pages in total when I do this. Im assuming this is because how I have my template set up.

So how would I go about setting specific page background for front and back, without changing my set up (2 master pages back and front)

Thank you.
Any help is appreciated
Kind regards
E

To set the front and the back of a Media you can apply something like the following:

Control Script

Name: Example
JavaScript code:

var stationery = merge.template.media["Media 1"].stationery;

stationery.front.enabled = true;
stationery.front.url = "Images/front.pdf";

stationery.back.enabled = true;
stationery.back.url = "Images/back.pdf";

TIP: See ‘Stationery object - PReS Connect 2023.1 User Guide (link)’ and ‘Front and back fields - PReS Connect 2023.1 User Guide (link)’ for more information.

Hi Marten,

Thanks for this I will give this a crack. Can I ask if I have one multipage pdf only can I suffix it with below to specify page?

“Images/artwork.pdf?page=1”

cheers
E

Please apply something like the following instead:

Control Script

Name: Example
JavaScript code:

var stationery = merge.template.media["Media 1"].stationery;

stationery.front.enabled = true;
stationery.front.url = "Images/artwork.pdf";
stationery.front.page = 1;
1 Like