Working with Leading and Trailing Spaces in DesignMerge Data Values

When processing variable data, it is sometimes necessary to preserve or add spaces at the beginning or end of a database value. These are commonly referred to as leading spaces and trailing spaces (or padding spaces, in general). This article provides a number of options for preserving padding spaces when working with AccurioPro VDP software.

PADDING SPACES IN VARIABLE DATA

For most variable data applications, extra spaces are unnecessary and can cause unwanted formatting issues. However, certain applications, such as barcode generation, fixed-length data fields, or specialized text formatting, may require spaces to be preserved or added intentionally.

AccurioPro VDP provides several options for controlling how these spaces are handled.

Understanding the Trim Spaces from Data Preference

By default, AccurioPro VDP automatically removes leading and trailing spaces from incoming database field values. This behavior is controlled by the Trim Spaces from Data preference.

When this preference is enabled, AccurioPro VDP removes spaces found at the beginning or end of data values read from the database. Spaces that occur between words or other characters within a data value are not affected.

For example, consider the following database value, where the quotation marks are included only to illustrate the spaces:

"   ABC123   "

With Trim Spaces from Data enabled, AccurioPro VDP processes the value as:

"ABC123"

With Trim Spaces from Data disabled, the original value is preserved:

"   ABC123   "

Although disabling this preference allows you to preserve spaces from the original database, it affects all data values processed by AccurioPro VDP. For this reason, we generally recommend leaving this preference enabled and using one of the following methods when spaces are required for a particular Variable Link.

Alternative Methods for Handling Padding Spaces

Method 1: Add Spaces Using Variable Link Prefix and Suffix Settings (Recommended)

AccurioPro VDP allows you to automatically add characters to the beginning or end of a database value using the Prefix and Suffix settings in a Variable Link definition.

These settings can be used to add ordinary text, special characters, or spaces.

Adding Leading Spaces Using a Prefix

To add spaces to the beginning of a data value:

  1. Open the Variable Link settings for the desired database field.
  2. Locate the Prefix setting.
  3. Type in the number of spaces you want to add before the data value.
  4. Save the Variable Link settings.

For example, if the original database value is:

"ABC123"

And the Prefix contains three spaces, the resulting value will be:

"   ABC123"

Adding Trailing Spaces Using a Suffix

To add spaces to the end of a data value:

  1. Open the Variable Link settings for the desired database field.
  2. Locate the Suffix setting.
  3. Enter the number of spaces you want to add after the data value.
  4. Save the Variable Link settings.

For example, if the original database value is:

"ABC123"

And the Suffix contains five spaces, the resulting value will be:

"ABC123     "

Important: Spaces added using the Variable Link Prefix or Suffix settings are not removed by the Trim Spaces from Data preference. This allows you to add spaces to individual data values without changing the global preference.

Of course, you can also use both Prefix and Suffix settings together if spaces are required at both ends of the data value.

Method 2: Add Spaces Using AccurioPro VDP Link Rules

Another option is to use AccurioPro VDP Link Rules to add spaces to incoming data values. Link Rules provide additional flexibility and can be particularly useful when the number of spaces or the need for padding depends on specific conditions.

Two Link Rule actions are available:

Add Prefix: Adds the specified characters or spaces to the beginning of a data value.

Add Suffix: Adds the specified characters or spaces to the end of a data value.

For example, a Link Rule using the Add Prefix action with three spaces would transform:

"ABC123"

Into:

"   ABC123"

Similarly, a Link Rule using the Add Suffix action with five spaces would transform the value into:

"ABC123     "

Link Rules are especially useful when padding must be applied conditionally or as part of a more complex data-processing workflow. As with the Variable Link Prefix and Suffix settings, spaces added through Link Rules are not removed by the Trim Spaces from Data preference.

Which Method Should You Use?

For most applications, we recommend leaving the Trim Spaces from Data preference enabled and adding spaces only where needed.

  • Disable the Trim Spaces from Data preference when you need to preserve the original leading or trailing spaces across incoming database fields.
  • Use Variable Link Prefix or Suffix settings when you need to add a fixed number of spaces to a specific data field.
  • Use Link Rules when spaces need to be added conditionally or as part of more advanced data-processing requirements.

Important Considerations

When working with spaces in AccurioPro VDP, keep the following points in mind:

  • Spaces at the beginning or end of a data value may not be visually apparent in the final document.
  • For applications that require an exact number of characters, such as certain barcode formats, verify that the resulting data contains the expected number of characters.
  • Prefix and Suffix settings add characters to the incoming data; they do not automatically calculate how many spaces are required to reach a particular field length.
  • If the original database value already contains spaces, consider how those spaces will interact with any additional Prefix or Suffix settings.

By using these features, you can precisely control leading and trailing spaces while maintaining consistent data handling throughout your AccurioPro VDP jobs.