2022.1

Table Of Contents
Setting a background in script
The Control Script should first enable a background on the section, in case an initial
background wasn't set via the user interface. This is done by setting the source type for the
background of the section to either DataMapper PDF orResource PDF (see
"BackgroundResource" on page1499). For example:
merge.template.contexts.PRINT.sections['Policy'].background.source
= BackgroundResource.RESOURCE_PDF;
For a DataMapper PDF, nothing else has to be done to set the background.For a Resource
PDF, the Control Script should specify a path, for example:
var resourceUrl = 'images/policy-' + record.fields.policy + '.pdf';
merge.template.contexts.PRINT.sections['Policy'].background.url =
resourceUrl;
Note
An image with an unknown file extension is represented by a red cross in the output, but
no error is logged unless the image refers to a local file that does not exist on disk.
Image file extensions that the software recognizes are: AFP, BMP, EPS, GIF, JPG/JPEG,
PCL, PDF, PNG, PS, SVG, and TIF/TIFF.
Positioning, scaling and rotating the background
After a background has been selected, it can be positioned, scaled and rotated, using
properties of the background object; see "background" on page1487.
To position the background, for example, set the section's background.position:
activeSection.background.position = MediaPosition.FIT_TO_MEDIA;
For all possible positions, see "MediaPosition" on page1503.
Setting a page range in script
When a PDF that serves as a dynamic section background has multiple pages, you can specify
a range of pages to be used, in a control script.
Page 964