Show/Hide Toolbars

CardExchange® Producer Help

 

CEDesigner_Setup_Expressions

 

The CardExchange® Producer Designer integrates a powerful script language that offers users a high level of flexibility when it comes to personalizing their card layouts. Instead of assigning fixed values to layout or layout-page properties, it is possible to control their values through expressions that yield different results in different circumstances. For example, CardExchange® Producer can inspect a field in the database and then decide to set a different background color, or even  show a completely different card layout.

The Expressions tab of the page-setup window allows for specifying expressions for the layout condition, a number of layout-page properties and any number macro commands. The layout condition is available for the Professional and Ultimate editions. The layout-page properties and the macro commands are only available in the Ultimate edition.

Expressions are written in IronPython (see http://ironpython.net), which is the .NET implementation of Python, (see http://www.python.org). Since the documentation of Python is publicly available on these websites, this help file will limit itself to explaining how Python can be used within CardExchange® Producer and giving some practical examples.

Layout condition

When a card template consists of multiple layouts, the layout-condition property can be used to determine whether a layout applies or not. Imagine, for example, that the template has two layouts and that we type

layout == 'A'

for the layout condition of the first layout. When pressing the Enter or Tab key or clicking OK, CardExchange® Producer will detect that a new variable called 'layout' was introduced and prompt for a default value. You could set the default value to 'A', as shown in the screen shot below.

Now close the page-setup window, select the second layout and open the page-setup window again. Type in the Expressions tab the layout condition

layout == 'B'

CardExchange® Producer will not prompt for a default value anymore, because the variable 'layout' is already part of the variables collection. Now when you look under the data tab of the explorer menu, you will see a sub tab for variables which contains a variable called layout. You can select this and from the properties window and map it to the field in the database that contains the layout condition.

The first layout will be shown for records that have the value 'A' in that field, while the second layout will only show if that field contains 'B'.

Layout conditions can be controlled by expressions that are much more complex than this. The expressions can contain functions and they can use multiple variables. It is possible to define the layout conditions in such a way, that for some records multiple layouts apply and for others no layout at all. CardExchange® Producer will print multiple cards for the same record if multiple layouts apply. If no layouts apply, CardExchange® Producer will skip the record when executing a print batch.

Background

Three layout-page properties can be controlled by expressions: the background color, the margins and the page orientation. Background colors are specified using HTML color names ('AliceBlue',  'AntiqueWhite', 'Aqua', etcetera) or using HTML color tags, for example, '#FFCD853F', specifying the alpha, red, green and blue channels respectively. The simplest way of getting a flexible background color is by just typing a variable name in the expressions box, like

backgroundcolor

 

CardExchange® Producer will prompt again for a default value, where you can type, for example, 'AliceBlue'. In the mappings window, the variable name will appear among the visible items and can be mapped to a database column that contains the desired color name for each record.

If the color is determined by a flag that does not reflect the color name directly, it is necessary to define a function in the Functions tab, like for example

def getcolor(flag):

if flag == 'A':

return 'Red'

elif flag == 'B':

return 'Green'

else:

return 'Blue'

 

This function can be used in the expression for the background color by typing

getcolor(flag)

where the variable 'flag' should be mapped to a database column that can contain the values 'A' or 'B'. As a result, CardExchange will show a red or green background if that column contains the value 'A' or 'B' respectively. he background will be blue for all other values.

Padding

The padding is the space between the edge of the card and the printed area, more commonly designated as margin when talking about pages. It is not commonly controlled by expressions. The result of the expressions should be either an integer value that specifies the width of the margin in pixels, or a string containing two or four numbers, optionally separated by a comma. The string '10 20' or '10,20' would set a margin of 10 pixels on the left and right sides and a margin of 20 pixels to the top and bottom sides. The string '1 2 3 4' or '1,2,3,4' would set a left margin of 1, a top margin of 2, a right margin of 3 and a bottom margin of 4.

Page orientation

For the page orientation, it is still more unlikely that you want to control it with an expression. The value that the expression should return are 'Landscape', 'Portrait', 'ReverseLandscape' or 'ReversePortrait', where the last two refer to an orientation that has been rotated 180 degrees.

Macro commands

Macro commands are text strings that are sent to the printer as printable characters, but that are interpreted by the printer as special commands. The most common application of macro commands is using them for magnetic encoding. The printer recognizes text strings as macro commands by inspecting the first and sometimes the last characters. For example, on certain printer brands, the string '~1%XXXXX?' is interpreted as a command to encode the characters 'XXXXX' on track 1 of the magnetic stripe.

Although you could define macro commands for magnetic encoding in the Expressions tab of the page-setup window, you normally will not do that, because it is much more user friendly to enable the magnetic-stripe object in the Page-layout ribbon and configure it in the properties window. However, some printers support other types of macro commands, for example for defining holographic overlays, in which case you can manually add those commands in the page-setup window.