2018.2

Table Of Contents
}
}
Note
For another example, see this how-to: Output sections conditionally.
Control Script: Setting a Print section's background
In the Print context, a PDF file can be used as a Print section's background. To learn how to do
this without a Control Script, see "Using a PDF file as background image" on page412.
With a Control Script, a Print section's background can be set dynamically. You could for
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751 and
"Control Script API" on page1162. If you don't know how to write scripts, see "Writing your own
scripts" on page722.
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 or Resource PDF (see
"BackgroundResource" on page1185). 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 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:
Page 759