Variable elements
- 3 minutes to read
You can use Customer's Canvas for variable data printing scenarios. In this case, some of the design elements become variable and populated later, for example, personal information on a business card, an address on an envelope, a barcode on a coupon, etc.
In this article, you will learn about two ways to configure the behavior of variable items: through the variable flag and through the interpolation placeholders.
Variable fields
You may mark the items that may hold content with a variable flag. It will make Customer's Canvas recognize it as a variable. Your code that populates a template with data will refer to this variable by the item's name. That's why it is important to give them consistent and meaningful names.
Not every item type allows for keeping content. For example, a text element, an image, or a barcode can be variable, while shape elements cannot.
For example, let's assume you want to add a variable for a phone number on a business card. You can do so as follows:
- Create a text element, for example, point text.
- Add some sample text, which will be displayed on previews or if the field is not populated.
- In the Layers panel, change the layer name to Phone.
- Click the Behavior tab.
- Scroll down to the Data group and toggle on Variable.
Interpolation placeholders
The variable flag works well on items where content should be replaced entirely. But what if you want to insert a variable inside a text block, like a name in a salutation?
In this case, you can create a variable by adding text surrounded by double curly braces. The content inside the braces will be a variable name. For example, you can do so as follows:
Create an area text element.
Edit its content like this:
Customer's Canvas will recognize a variable named First Name in this text element.
Helpful tips
Interpolation placeholders are case sensitive
It is possible to add the same interpolation placeholder to several places. All entries will be populated with data during the VDP processing. However, note that the names of variables are case-sensitive - {{Name}} and {{name}} will be recognized as different placeholders.
Don't use both methods on the same element simultaneously
Do not make an element variable if it contains interpolation placeholders. In this case, Customer's Canvas will recognize the entire block as a variable, and when inserting values there, these placeholders will be lost.
Having said that, you can mix a variable flag and interpolation placeholders if they are applied to different elements. However, avoid using the same names for them.
Customer's Canvas will recognize them as different elements. Although the application that applies the variable data may handle this, you can simplify things if you are using the same method to mark variable fields with the same name. For example, if you already have an inline variable and you need to insert the same data to a standalone item, you may create a text element consisting only of an interpolation placeholder.
Same formatting on interpolation placeholder
An interpolation placeholder must maintain single formatting. Do not apply different styles inside of a placeholder. In this case, Customer's Canvas won't be able to recognize the variable.