2018.2

Table Of Contents
example specify a particular PDF file as a section's background depending on the value of a
field in the current record. This topic shows how.
Note
Encrypted PDF files are not supported in PDF pass-through mode.
For information about Control Scripts in general, see "Control Scripts" on page369 and
"Control Script API" on page749. If you don't know how to write scripts, see "Writing your own
scripts" on page340.
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 Resource PDF (see "BackgroundResource" on page770). For
example:
merge.template.contexts.PRINT.sections['Policy'].background.source
= BackgroundResource.RESOURCE_PDF;
A DataMapper PDF is, as you would expect, a PDF generated by the DataMapper. A Resource
PDF is a PDF from another source.
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;
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761.
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773.
Page 377