Dynamic media and input tray selection

The input tray in a printer functions as the source for paper. When you’re configuring media within your OL Connect template, you have the option to associate these media names with the printer’s input trays. Media can either be static or dynamically set. Dynamic media is typically used in scenarios where different brands need to be printed on pre-printed paper stock depending on the value of a data fields or when special paper types apply to parts of your documents.

In this tutorial, you will learn a technique to dynamically set Media for print sections and map these to input trays.

This tutorial illustrates how to switch between different media types based on specific data conditions. We will utilize media entries located in the Media folder, which is accessible through the Resources view of the template. These media entries are named with the company’s name as a suffix, matching the data provided in the brand data field. After configuring the template, we will demonstrate how to link the template-defined media with input trays using an Output Preset.

Steps

In our document we’ve set up Media entries for every brand variant. For every brand we have pre-printed paper stock. The Media entries use a background image in PDF format to mimic the preprinted paper stock, which helps visualize the final output while working on the template in OL Connect Designer.

Setting up Media in the template

Changing the Media dynamically requires a Control Script. Control Scripts determine how different sections of the context are handled. They can be used to omit Print sections from the output, clone Print sections and, in this particular case, set the Media for our print section.

To create the Control Script:

  1. Choose Control Script from the New Script icon located in the toolbar of the Scripts pane.
  2. Enter a name for the script and delete the sample code.
  3. Add the code below. It stores the section entry and the value of the brand data field in the section and brand variables. This helps us keep the code tidy.
var section = merge.template.contexts.PRINT.sections["Section 1"]
var brand   = record.fields.brand
  1. Add the following code to the script. The first line validates is the brand variable is set. If it’s not, the print section will utilize the Media specified in the Sheet Configuration dialog. The second line assigns the Media for all sheet positions by generating the name of the desired media entry in the Resources based on the value stored in our brand variable.
if( brand ) {
    section.sheetConfig.positions.all.media = `Media ${brand}`
}

The complete script looks like this:

var section = merge.template.contexts.PRINT.sections["Section 1"]
var brand   = record.fields.brand

if( brand ) {
   section.sheetConfig.positions.all.media = `Media ${brand}`
}
  1. Click OK to save the script and toggle to the Preview mode to view the script in action.

This is all that is needed to dynamically toggle the Media entries. Let’s now have a look on how to map these to input trays on the printer.

Tray mapping

The following steps describe how to setup the tray mapping when printing the documents. You can save these settings as an Output Preset for future use in other print jobs or when integrating with automation tools like OL Connect Workflow. Tray mapping is supported on AFP, IPDS, PCL, and PostScript printers configured for cut-sheet printing.

Follow these setps to configure tray mapping:

  1. Go to the File menu and choose Print.
  2. Click Advanced to display the Advanced Print Wizard interface.
Important! If you’ve added virtual stationery backgrounds to the media in your template and your trays container pre-printed stock, make sure not to select the “Print virtual stationery” option. Otherwise, the background image will get printed over your pre-printed paper.
  1. Next, choose a cut-sheet printer model and click Next. The Printer Settings step appears showing the Tray Mapping options and a list of the Media entries from the template.
  2. Set the Map media by to Tray and specify the tray that holds the respective paper source you want to use.
  1. Once you’ve configured the tray mapping, click the Print button to proceed with printing your document using the specified tray settings.