Creating a Snippet

Snippets are a reusable piece of label, which makes them a useful label building tool

Lucas Tran avatar
Written by Lucas Tran
Updated over a week ago

By setting up a snippet, you can place it any where on a label, and across multiple labels without having to rewrite the code that goes into building the template.

To configure a snippet, start by giving the snippet a Model ID, and a description. Select the snippet model type and select the size format of your snippet. Although not required you can select a margin. Complete the selection with the layout and a classification. One thing to note, when a snippet is place on a label, they will only occupy the amount space needed. In other words, even if you select a specific format, like 4x4, your snippet won’t take up a 4x4 space on the label.

Snippets can be used in multiple ways, whether it’s using the snippet to repeat an image, a text field, such as an address, or anything you think that may be repeated in a label. There are different uses cases for your snippet. All of it depends on how you write the template.

In this case, we will be showcasing 2 simple snippets: a short text and an image snippet.

Text Based Snippet

The following snippet template may look intimidating; however, we will go over it line by line.

The first line is the SaveFont function, which is a function that save the original font used in the label. This allows the snippet to have its own font (if needed) without affecting the font used in the overall label it will be placed in.

The second line is a set of functions that essentially dictate the height and width of the font used in the snippet. If the height is not defined in the snippet definition on the label, the default height it will take is 45.

The third line is the font definition itself. This snippet uses font ‘N’ which is a proportional font.

The fourth line is the variable definition. This is where a code, based on the brace expression, will be generated in the expressions tab, and we will map a specific expression to the code. In this case, only a sample value was placed, the value being the “Snippet text”.

The last line is the RestoreFont function, which is a function that restores the original font used in the label. Therefore, any field following the snippet will have the original saved font used in the label.

Image Based Snippet

When it comes to making a snippet with an image, the process is simple. In the template, define a variable using brace expressions. In the expressions tab, use the Image function to import the image file. It is important to note that the image uploaded to the system should have a transparent background.

Result

Given that everything is already configured in the respective snippet, all that needs to be done to insert the snippet in the label is to make the call using the include function. No redefinition of the snippet is needed.

Did this answer your question?