Creating document variants based on data and a collection of pre-produced designs is a typical variable data printing scenario. These could be brochures with information of a reseller/dealership, postcards with an audience specific design from a library or personalised letters with recipient and sender information.
In OL Connect Designer switching these designs is commonly achieved by writing a control script to dynamically set the background image of a section. Version 2019.2 introduced a new scripting wizard to create such documents in a breeze and without having to write any code.
This article explains how to use the Dynamic Section Background wizard to create postcard variants based on a collection of images and a matching data file. The data file contains information about the recipients and their favorite travel destination.
The design files
The postcard designs are created in Adobe Illustrator and stored as PDF in a folder on disk.
Each design consists of two pages: the front and back of the postcard. The image below shows the
japan.pdf card opened in Acrobat Reader (Two Page View).
The sample data
The value of the
destination data field in the data holds the basename of the design files (e.g. japan, india, egypt and australia). This information will be used to construct the dynamic path. A sample data record looks something like this:
<record> <first>Mano</first> <last>Gutierrez</last> <country>United States</country> <street>74 Chinook Hill</street> <city>Washington</city> <postal>20319</postal> <state>DC</state> <address>Mano Gutierrez<br>74 Chinook Hill<br>Washington, DC 20319</address> <destination>japan</destination> </record>
Create a new Connect template
You can create a new template right from the File system.
- Download and extract the sample designs: travel designs.zip.
- Right click one of the design files and choose Enhance with Connect from the contextual menu. The New PDF-based Print Template wizard appears. The Path field holds the full path to the selected image file.
- Uncheck the Save with template option. By default the selected image is added to the Images folder of the template and used from that location. In this example we want to use the images from the folder on disk.
- Click Finish. A new document is created showing two pages. The selected image is set as background for the initial section. When using a multi-page PDF as section background a page for each page in the PDF is automatically added to the document.
Note! The Enhance with Connect option reads the page size of the selected PDF and creates a new template using these dimensions.
Note! When producing the final output via OL Connect Workflow running on a different machine one has to make sure that the specified folder is accessible by that machine. Alternatively one could add all image variants to the Resources folder of the template and set one entry to the background of the print section manually.
Load the sample data
- Download and extract the sample DataMapper configuration: travel datamapper.zip
- Open the travel.OL-datamapper and toggle back to the template editor.
- The Data Model panel shows the data fields and the values of the first record.
Setup the dynamic background
- Right click the print section (Section 1) in the Contexts folder of the Resource panel. Choose Dynamic Background. The Dynamic Background wizard appears. Several options of the wizard are automatically set based on the image we selected to create the document.
- The Location is set to Folder on disk.
- The Path field points to the folder holding our image.
- The Suffix for the first field row is to .pdf. These options define the basis for the dynamic image path. All what is left is selecting the data field holding the basename of the images.
- Select destination in the Field-dropdown of the first field row.
- Click OK. A new script entry is added to the Control section of the Scripts panel. Control scripts run before standard personalisation scripts.
Toggle to the Preview mode and browse through the records to see the various images being applied to the section background.