Technical Document
EnglishCreating Intelligent Templates™
USING DYNAMIC DESIGN TECHNIQUES TO PRINT
MULTIPLE OUTPUTS BY USING A SINGLE DOCUMENT
SUPPORTS: BARTENDER ® 2019 AND LATER VERSIONSContents
Overview
Dynamic Design Techniques
Conditional Printing
About Conditional Printing
Using conditional printing
Conditionally Printing Objects
ExampleConditionally Printing Layers
How layers work in BarTender
ExampleConditionally Printing Templates
Example 1: Conditionally printing templates
Example 2: Using template selectors
Using Visual Basic Script
Document-Level Events
Changing Object Properties by Using VBScript
Example 1
Example 2
Example 3
Example 4
Support for Data-Sourced VBScript
Automatically Sizing Objects
Using Auto Fit for Text Objects
ExampleUsing Auto Fit for Barcode Objects
ExampleAutomatically Sizing Picture Objects

3
3
4
4
4
5
5
5
6
6
8
9
10
11
11
12
12
12
12
13
13
14
14
14
15
16
16

ExampleUsing Suppression
ExampleAppendix A: Task Reference
Related Documentation

16
18
18
19
20

OverviewAs the popularity of complex and variable designs increases, so does the need for dynamic design
techniques. Companies can use BarTender to create Intelligent Templates™ to produce a wide
variety of flexible label designs without having to create and maintain hundreds of separate
documents, so that you can vary the image, color, object position and text on each item that you
print.
For example, one Intelligent Template generated all of the following membership cards by using avariety of dynamic design techniques. This technical document describes these techniques in detail.

Dynamic Design Techniques
Use one or more of the following techniques to create a dynamic design:
l

l

l

l

Use conditional printing to set conditions that specify when objects, layers or entire
templates are printed.
Run custom Visual Basic script (VBScript) in response to certain document-level events. By
using VBScript, you can alter any object's appearance by changing its color, font, position, size
or border.
Use automatic sizing for text, barcode and picture objects to make the objects fit adesignated space on your template.
Use suppression to automatically hide text on your template based on conditions that you
specify.

Creating Intelligent Templates™

3

Conditional Printing
Use conditional printing to specify exactly when different objects, layers or templates in yourdocument are printed. For example, you can configure a graphic to be printed under one condition
but not under any others. Or, you can choose to print a template based on a value in your database.
You can conditionalize printing for as much or as little of your design as you want.

About Conditional Printing
Conditional printing is based on conditional operators. For example, your conditions for printing might
be based on whether the conditionalized item contains or does not contain certain text, numericvalues, or images, or on whether the conditionalized item is less than, greater than, or equals aparticular value.
You can apply conditional printing to objects, layers or templates, depending on how much of yourdesign you want to change at print time.

Using conditional printing
To use conditional printing, use the When to Print dialog in BarTender to specify a conditional
statement that is based on a database field or a named data source value to determine when
the object, template or layer is printed.

Creating Intelligent Templates™

4

For more information, refer to the following topics in the BarTender help system:l

Conditional Printingl

Building Conditional ExpressionslWhen to Print Dialog

Conditionally Printing Objects
When your design calls for only one object to change for multiple items, consider setting up
conditional printing for that one object. When you do this, you can print (or not print) one object
based on conditions that you specify. This technique is useful when you need different objects toappear in variations of the same template.
Any of the following objects can be conditionally printed:l

Barcodesl

Encoder objectslText objectslLine objectslShape objectslLayout grid objectslTable objectsl

Pictures

ExampleIn this example, the document is connected to a database that includes a list of conference
attendees and their status. The When to Print dialog was used to configure the bottom text
object to be conditionally printed based on whether the attendee has a status of "VIP." Noticethat the position, formatting and visibility of all other objects on the name tag remain the same,
regardless of whether the status is printed.

Conditionally Printing Layers
When you have a complex design in which multiple objects are the same among all designs but otherobjects change, consider using conditional layers. A layer is an object or group of objects thatoccupies a single plane. Layers are stacked on top of one another.

Creating Intelligent Templates™

5

How layers work in BarTender
In BarTender, each layer can contain one or more objects. When you need to dynamically print
multiple objects on your template at different times, you can put the objects on different layers
and then conditionalize the layers to be printed when certain conditions are met. You use theWhen to Print dialog for each layer to specify when that layer is printed, just as you do when you
conditionalize an object.

ExampleIn this example, the following base layer includes all of the objects that remain the same on all of
your designs.

Each subsequent layer includes the objects that differ on each of your designs. Each layer can
include one or more objects, as shown.

Creating Intelligent Templates™

6

After you conditionalize each of the subsequent layers by using the When to Print dialog, thelayers are printed on top of the base layer based on the conditions that you set. The final print
output for this example is as follows.

Creating Intelligent Templates™

7

For more information about layers, refer to the following topics in the BarTender help system:lUsing LayerslLayer Properties Dialogl

Arranging Layers on a Template

Conditionally Printing Templates
When one piece of information can alter the entire layout of the document that you want to print,
consider creating two or more different templates for the same document. You can configure
templates to be printed by using either conditional printing or template selectors.
Consider the following example. Your company has two offices, one in Seattle and the other in New
York. All of the employees are listed in the same database, and you need to print business cards forall of the employees. The office in Seattle uses one design for their business cards, and the office in
New York uses a different design. Each design is saved as a separate template within the same
BarTender document.

The following examples describe how to configure conditional printing for this scenario by using bothconditional printing and template selectors.

Creating Intelligent Templates™

8

Example 1: Conditionally printing templates
By using conditional printing, you can specify multiple conditional expressions for each template,and you have a lot of flexibility for specifying print conditions.
For example, suppose that your database has a "City" field that includes multiple different
spellings for the same city (New York, New York City, NYC). To address the discrepancies interminology, you can define multiple conditional statements so that you can print items for all thevariations of "New York" in the database.
To do this, specify your conditional statements in the When to Print dialog to instruct BarTender
to print the document when it encounters "New York", "NYC", or "New York City" in the "City" fieldof the database, as shown.

Repeat this procedure for the Seattle template to instruct BarTender to conditionally print the
template when the "City" field contains the values "Seattle" or "SEA".
As a result, if the value that BarTender reads from the database is "New York", "NYC", or "NewYork City", the New York template is printed, and if the database value is “Seattle or "SEA",” theSeattle template is printed.
For more information, refer to the following BarTender help topics:lPage Setup DialoglWhen to Print Dialog

Creating Intelligent Templates™

9

Example 2: Using template selectors
Template selectors provide a simple way to choose among templates
when you know all the values that could appear in your data source.
When you use a template selector, it determines which template toprint based on the content of the data source. Note that the data
source must match the name of the template for the template to beprinted.
For example, suppose that the only values for the "City" field in the
database are "Seattle" and "New York" and that the names of yourtemplates match these values.
On the Templates tab of the Page Setup dialog, add a new template selector. Drag both the
Seattle and New York templates to the template selector. Then, select the value that you want
to use to match the template name. In this example, select the "City" database field.
As a result, if the value that BarTender reads fromthe database is “Seattle,” the Seattle template is
printed, and if the database value is "New York,"
the New York template is printed.
For more information about template selectors,
refer to the Using Template Selectors topic in the
BarTender help system.

Creating Intelligent Templates™

10

Using Visual Basic Script
Visual Basic Script (VBScript) is a very flexible language that you can use to programmatically modify
objects at different times throughout the document design and print process.
You can use VBScript to change object properties such as size, location and color, in combination
with any other variables that you can script. For example, you can change an object's color based on
the time of day or change an object's size based on the color of another object. VBScript is perhaps
the most dynamic template design tool of all, because when you have the appropriate programmingskills, you can accomplish almost anything that you want in your BarTender document.

Although Visual Basic scripts can be complex enough to beconsidered "programs," sometimes a single line of VBScript can provevery useful. However, scripting is typically a technique for power usersthat is not ideal for beginners. In any case, we recommend that you
determine whether BarTender offers a solution to your challenge
before you try using a script-based solution. For more information,refer to the Visual Basic Scripting book in the BarTender help system.
For a complete listing of object properties that you can dynamically change by using VBScript, refer tothe Template Objects topic in the BarTender help system.

Document-Level Events
You can use VBScript to modify objects in
a BarTender document only by using
document-level event scripts, such as
opening or closing a document, starting aprint job, reading a database record, andso on. To write scripts for these events,
use the BarTender Document Options
dialog to enable document-level script
events. Once this feature is enabled, you
can write scripts for the events by using
the Visual Basic Script Editor.
For more information about the available
document-level events that you can use
for Visual Basic scripting and how to open
and use the Visual Basic Script Editor,
refer to the following topics in the BarTender hep system:lDocument-Level EventslVisual Basic Script Editor

Creating Intelligent Templates™

11

Changing Object Properties by Using VBScript
The following examples describe how to change object properties by using VBScript.

Example 1
A common use case is to change an object’s color in response to the data that is coming from a
database.
In this example, you want to make an object's text color gold, silver or bronze, depending on
membership level. To do this, enter script that resembles the following in the Editor pane of the
Visual Basic Script Editor.
Set Notice = Objects("Text 1")
If (Field("MembershipType") = "Gold") Then
Notice.TextColor = btColor.Gold
Else
If (Field("MembershipType") = "Silver") Then
Notice.TextColor = btColor.Silver
Else
If (Field("MembershipType") = "Bronze") Then
Notice.TextColor = btColor.DarkGoldenrod
Else
Notice.TextColor = btColor.BlackEnd IfEnd IfEnd IfExample 2
If your database includes a column that contains the name of a color, you can use VBScript to
set the color of an object by reading the color from the database. To do this, enter script that
resembles the following in the Editor pane of the Script Editor.
ReferenceField("ConditionColor")
Objects("Box 1").FillColor = Eval(Field("ConditionColor"))

When you do this, the "ConditionColor" field in your database can contain values such as"BtColor.Red" or "BtColor.FromRGB(255,0,0)".

Example 3
You can use VBScript to change the properties of linked objects and embedded objects or toswitch among the objects. The following sample code uses VBScript to switch between two
linked image objects based on conditional values.
ReferenceField("Image")
Set ImageObject = Objects("Picture 1")
If Field("Image") = "Black" Then
ImageObject.PicturePath = "C:\vbscriptimagepath\images\BarTender_Black.png"
Else
ImageObject.PicturePath = "C:\vbscriptimagepath\images\BarTender_RGB.png"
End IfCreating Intelligent Templates™

12

Example 4
You can hide or show objects based on the data that is read from a database or named data
source. To do this, you can use an object’s PrintVisibility property, or you can move the object onor off the design area by using its X and Y properties.
For example, if you want a line object to appear only if a "Location" database field has the value"Seattle," enter script that resembles the following in the Editor pane of the Script Editor.
Set Notice = Objects("Line 1")
If (Field("Location") = ("Seattle")) Then
PrintVisibility = True
Else
PrintVisibility = False
End If

Support for Data-Sourced VBScript
You can feed VBScript into BarTender from external sources, such as a database or a program thatis controlling BarTender. For example, you might configure a field in a database to contain VBScript
code. Then, when BarTender reads the data record that contains that field, VBScript code in
BarTender can use the Visual Basic “Execute” statement or the “Eval” function to run the imported
VBScript.

This is an advanced technique that should be used only by users who
have extensive VBScript experience or who have the help of a
BarTender reseller or other consultant.

Creating Intelligent Templates™

13

Automatically Sizing Objects
BarTender can automatically adjust the size of objects on your template based on the data that iscontained in the object. You can configure the sizing settings by using the Object Properties page fora text, barcode, or picture object, as follows:lll

For text objects and the human readable text portion of barcode objects, you can use the AutoFit property page to change the font size, scale and spacing of the text to make it fit theavailable space on the template.
For barcode objects, you can use the Auto Fit feature to automatically fit the barcode symbol
to a width that you specify.
For picture objects, you can use the settings on the Picture Properties page to make sure thatthe pictures automatically fit a specified space on the template.

Using Auto Fit for Text Objects
The Auto Fit feature configures the size of the text to fit into the text object that you have specified on
the template. The text object itself stays the same size; only the text inside the object is adjusted.
To use this feature, click Auto Fit in the navigation pane on the Text Properties dialog for the text
object, and then click to select the Automatically fit text to specified dimensions check box. Afteryou do this, you can specify the dimensions, alignment, minimum and maximum font point sizes, fontscale width, and character and line spacing .

ExampleSuppose that you are creating mailing labels and that certain fields contain more address
information than others. For example, some customer names and company names are longer

Creating Intelligent Templates™

14

than others and exceed the label dimensions. By using Auto Fit for these text objects, you ensurethat they always fit on your label.
When you apply Auto Fit to the text objects that correspond to the "Customer Name" and"Company Name" fields of your label, the text size adjusts to fit the available space, as shown.

Using Auto Fit for Barcode Objects
You can use the Auto Fit feature for both the barcode symbol and the accompanying humanreadable text, so that regardless of the length of the data source, the objects that contain yourbarcode symbol and human readable text maintain a consistent size. You configure the Auto Fit
settings separately for the symbol and the text.
When you use Auto Fit to configure the human readable text, the text automatically fits into
dimensions that you specify. To do this, click Auto Fit in the navigation pane on the Barcode
Properties dialog, and then click to select the Automatically fit text to specified dimensions checkbox. After you do this, you can specify the dimensions, alignment, minimum and maximum font point
sizes, font scale width, and character and line spacing .
When you use Auto Fit to configure the barcode symbol, BarTender adjusts the X dimension tomaintain the symbol size that you want. To do this, click Symbology and Size in the navigation paneon the Barcode Properties dialog, clicknext to the X Dimension field, and then click to select the
Automatically fit barcode to specified width check box. After you do this, you can specify the symbol
width and maximum and minimum X dimension widths that you want.

The barcode width that you specify is the maximum width that thebarcode uses. Therefore, depending on the data source value, thesymbol that is printed might be smaller than what you specify.
Because Auto Fit can affect the density (and consequently, thereadability) of data, we recommend that you test your scanner’sability to read barcodes at both your minimum and maximum
settings.

Creating Intelligent Templates™

15

Example
Suppose that you are printing labels andthat each label has a specified area
where one of four barcodes appear. The
barcodes contain varying amounts of
information and human readable text,
but you need all of them to fit within thespecified area on the template.
Depending on the barcode type and the values of the connected data source, your results when
you use Auto Fit might resemble the following sample labels. Notice that the X dimension of thebarcode symbol becomes smaller as the data source (indicated by the human readable text)
increases in length so that the symbol maintains its width.

Automatically Sizing Picture Objects
You can configure picture objects to automatically fit a specific area on the template. To do this, use
the picture object's Picture Properties dialog.

ExampleSuppose that you want to create labels to mark sale items and that you want the picture of thecurrent sale item to appear in a particular place on the template. You have multiple pictures that
can appear on the label, and not all of the pictures are the same size. You need all the picturesthat appear on the template to be printed at the same size.
To do this, click Size in the navigation pane of the Picture Properties dialog, and then configure
the sizing settings that you want. Then, click to select the Lock Size check box. When you do this,any picture that you use for that object appears at the size that you selected.

Creating Intelligent Templates™

16

Creating Intelligent Templates™

17

Using Suppression
You can use the suppression feature in BarTender to conditionally print data sources. Suppression
differs from the conditional printing methods that were described previously in that data sources aresuppressed, or hidden, when a condition is met.
Suppression is commonly used for a wrapped text object that contains separate data sources foreach line in the object, but in which a data source might not contain data. When the data source
does not contain data, you might want to configure BarTender to automatically suppress the data
source so that it doesn't appear on the label as a blank space.

ExampleSuppose that you have a wrapped text object that uses multiple data
sources for an address label. The data sources are linked to databasefields that are called CustomerName, CompanyName, Address1,
Address2, City, State, and Country. To create line breaks between theaddress lines, an Embedded Data data source that contains only acarriage return is added after each Database Field data source.
For some records in the database, there is no data in the"Address2" database field. You want to eliminate the blank space thatappears on the label if the "Address2" data source is empty.
To do this, on the Transform tab on the Data Sources property page,apply the Suppress when previous data source is empty suppression
rule to the carriage return data source that follows the "Address2" data source. By suppressing
the carriage return when there is no data for the "Address2" data source, you eliminate theblank space.
As a result, your address labels are printed without a blank space when the "Address2" field isempty.

For more information about suppression, refer to the Suppression Dialog topic in the BarTender help
system.
For more information about how to read data from databases, refer to the Reading Data from
Databases topic in the BarTender help system.

Creating Intelligent Templates™

18

Appendix A: Task Reference
The following table describes common dynamic design tasks and the methods that we recommendthat you use.
Task

Recommended Methods

Show or hide a single object based on the data that is read

Conditional printing for objects

Show or hide multiple objects based on the data that is read

Conditional printing for layers

Change the color of an object based on the data that is read

Conditional printing for layers
VBScript

Change the font size of a text object based on the data that is read

Auto Fit for text

Hide the contents of a selected data source under certain conditions

Suppression

Change the size of a barcode object based on the data that is read

Auto Fit for barcodes

Change the position of an object based on the size or other properties
VBScriptof another object
Change part of a template design based on the data that is read

Conditional printing for layers

Change the entire template based on the data that is read

Conditional printing for templates
Template selectors

Creating Intelligent Templates™

19

Related Documentation
Technical DocumentslColor Coding Your Items

To view and download technical documents, visit:https://www.seagullscientific.com/resources/white-papers/

User GuideslGetting Started with BarTender
https://support.seagullscientific.com/hc/categories/200267887

BarTender Help Systeml

Building Conditional ExpressionslConditional PrintinglUsing LayerslSuppression DialoglUsing Template SelectorslVisual Basic ScriptinglReading Data From Databases

Other Resources
Please visit the BarTender website at https://www.seagullscientific.com.
To learn more about conditional printing, please visit the BarTender Support Center website athttps://support.seagullscientific.com.
l"Introduction to conditional printing" (WEB)https://support.seagullscientific.com/hc/en-us/articles/205643327-Introduction-to-conditional-printing© 2020 Seagull Scientific, Inc. BarTender, Intelligent Templates, Drivers by Seagull, the BarTenderlogo, and the Drivers by Seagull logo are trademarks or registered trademarks of Seagull Scientific,
Inc. All other trademarks are the property of their respective owners.

Version 2020-10-30 Copyright © 2020 Seagull Scientific, Inc.