2019.1

Table Of Contents
Setting a page range automatically sets background.allPages to false (see "background" on
page824).
On the other hand, when you first define a page range and then set background.allPages to
true, this disables the page range.
Tip
You could use the resource() function to check the number of pages or for example the page
height and width before setting it as a background (see "resource()" on page816).
Example
This scripts sets a background on a Print section using absolute positioning.
var activeSection = merge.template.contexts.PRINT.sections['Section
1'];
activeSection.background.source = BackgroundResource.RESOURCE_PDF;
activeSection.background.url = "images/somepage.pdf";
activeSection.background.position = MediaPosition.ABSOLUTE;
activeSection.background.left = "10mm";
activeSection.background.top = "10mm";
You could replace the last three lines of the previous script by the following line to scale the
Print section background to Media size:
activeSection.background.position = MediaPosition.FIT_TO_MEDIA;
Dynamically adding sections (cloning)
This topic explains how to clone a section in a Control Script. Print sections can be cloned, so
that a document can have a dynamic number of sections, based on data. This is particularly
useful when the record set defines one or more PDFs (e.g. insurance policies) per recipient.
Via a Control Script, for each PDF a section can be cloned and each clone can be given one of
the PDFs as background (see "Control Script: Setting a Print section's background" on
page398). For each page in the PDF, a page will be added to the section.
For information about Control Scripts in general, see "Control Scripts" on page390 and
"Control Script API" on page811. If you don't know how to write scripts, see "Writing your own
scripts" on page360.
Page 400