Watch the Video Tutorial

Using Variable Data in Illustrator will save you a lot of time and avoid entry errors. It allows you to re-use the same artwork with different data in it. A good example would be to output business cards for a company for hundreds of different individuals.

Create a Workspace

Before we get started, we’ll create a ‘Variable Data’ workspace in Illustrator.

  1. Type Shift-Tab to hide all of your panels.
  2. Open your Layers and your Variables panels.
  3. Save the workspace as Variable Data.

Types of Variables

illustrator-variable-types

Objects such as point type, area type, vector art and placed images are containers for the data stored in the spreadsheet. They’re simply place-holders which will be replaced by each row of data as the file is exported with our Batch Action.

Text string

This type of variable looks to the spreadsheet’s rows for text. As it progresses through the rows, it swaps out the text in the Illustrator document for each entry in the data. This is the most common type of variable. It can be point text or area text.

Image variable

You can swap out placed/linked images based on the data in a spreadsheet. Because we’re using the VariableImporter script, we don’t even need to specify the paths to our images in the spreadsheet.

Visibility variables

This is artwork we wish to reaveal or hide, determined by the presence of a character in the field of the spreadsheet.

Graph variables

You need to create an Illustrator Graph to start. The graph data for each record must be saved in a text file. In the VariableImporter panel, select the folder with all the data text files. Upon importing the data, the script will pull the data from each text file.

Installing ‘VariableImporter’ Script

Rather than editing the raw XML, we’ll use a script which will offer a graphical user interface to edit it for us — much easier.

Installing the Variable Importer Script

We’ll use a free script called “Variable Importer” to edit the raw XML document in a graphical user interface. This will make the job quite a bit easier.

This is where the Variable Importer script needs to be installed so it’s accessible from Illustrator’s Scripts menu.

illustrator-path-to-scripts-folder

Thanks goes out to Vasily Hall, the author of the script.

Once you’ve placed the scripts in the folder, quit and re-launch Illustrator to make it available in the Scripts menu. File > Scripts

If we name objects on artboards properly, the script will bind them to variables automatically. We want to name objects in the Layers panel to match it to the column headers in our data file. In naming things, remember these criteria:

  • no special characters are allowed, &, $, #, etc…
  • no spaces are allowed.
  • they are case sensitive.
  • the image variable column header needs to be prefixed with a @ symbol.
  • a visibility variable column header needs to be prefixed with a # symbol.
  • a graph variable needs to be prefixed by a % symbol.

Editing Your Data

We’ll need a properly formatted spreadsheet in order to create the multiple files from our data. We’ll set this up here.

In our spreadsheet, columns are variables. Rows are the data sets which contain those variables. When showing the next data set in Illustrator, we’re just moving to the next row in the spreadsheet. Each coloumn represents an object on your Artboard. Column heads cannot have spaces or special characters. They should be readable and descriptive.

  • An @ symbol before the column name represents an image.
  • The # symbol before the column name represents a visibility variable.
  • A % sign before the column name represents a graph.

Go to the Google spreadsheet from this link.

illustrator-variable-data

@ Working with Images

You can paste in the image names from Finder to the image column in your spreadsheet. You do not need to include path to the image in Finder. The script will take care of this for us. Yay!

# Working with Visibility

Visibility is only ‘On’ or ‘Off’. In your spreadsheet, that’s expressed as TRUE or FALSE. Again, the header for a visibility variable is prefixed with a # symbol. You can actually type any character into the field. If there’s any character, the script will interpret it as TRUE. If the field is blank, it will interpret it as FALSE. This is how you show or hide objects on the Artboard.

% Working with Graphs

Graph data needs to be saved as a .txt file. Each file contains the data from the Illustrator Graph Data panel. So you need to copy the data from that Illustrator panel into a spreadsheet. The data needs to be separated by tabs and not commas.

About Paragraph Breaks

If you have content which is paragraphs of text, you’ll need to create breaks between them. To get separate paragraphs in variable text, you need to type two backslash \ characters. That will start a new paragraph after the two backslashes.

Formative Activity

Download the spreadsheet so you can edit it on your computer. Use any spreadsheet app you have. Apple’s Numbers app is preferable. Add @ or # in the column headers where appropriate. Make sure the sub-layer names in the panel match the column headers, without the symbols.

Create columns as needed. They’re a @ symbol to swap out images. They can also be a # to create a visibility variable. This opens up many possibilities depending on how you set up the artwork on your artboard.

Exporting Your Data

Once our data is well formatted in a spreadsheet, we need to create a file our Variable Importer script will understand. We’ll create a .csv file.”

The script accepts comma-separated or tab-separated text. This is why we need to Save As or Export our spreadsheet. The script will accept either. Let’s use a comma-separated (or .csv) file.

illustrator-variable-csv-file

Importing Data

This is the stage where the script really shines. We’ll use it to import the data from the .csv file and feed it our images. Choose: File > Scripts > VariableImporter…

Next, choose the data file (the .csv). You’ll see your data apply in the window. Double-click in any rows which contain images to give it the path to the folder with those images. In most cases, this will do. Click ‘Import Variables’.

Once you’ve imported, you’ll see that your Variables panel has been populated.

illustrator-variable-script

You can use the Forward and Back buttons to cycle through your data sets. Make sure you check for overset text and image issues on each artboard before exporting to separate files.

This is really the end of the variable data part of the assignment. All that’s left is to output separate files in whatever format you need. We’ll create PDF files.

Updating Data Sets

Once you’ve imported your data, you can cycle through the records to check for errors.

If you find an error on your Artboard, you can fix things right in Illustrator. If you do make a change on the Artboard, you need to click on Update Data Set from the Variables panel menu. Avoid doing this, since the changes won’t be there if you import variables again.

cg5-03-illustrator-update-variables-panel

It’s preferable to make the change in the spreadsheet in case you re-import. That way the correction will stick around.

illustrator-variable-csv-file

Dealing with Overset Text

Overset text is the bain of data-driven graphics. It’s really a pain. Illustrator will not warn you there’s overset text during this process.

You’ll need to simply go through each record to visually check for overset text. The best idea is to actually plan to have short text from the outset. If you encounter overset text, you’ll need to fix it, then re-output the files.

illustrator-variable-overset-text

Exporting Data Sets

Variable Data in Illustrator is a little-know feature that can save you hours of teadious, error-prone work.

We’ll use an Illustrator Action in a Batch to export each record.

  1. Name a new action as ‘Save Data Set as PDF’.
  2. Choose File > Save a Copy…
  3. Don’t change the file name.
  4. Choose PDF as your file format
  5. Choose PDF settings to suit your needs.
  6. Make sure ‘View PDF after saving’ is checked off.
  7. Click Save PDF
  8. Stop recording

Now we’ll use the Batch command to run the action on our data sets.

  1. Go to the Actions panel and choose Batch… from the flyout menu.
  2. In the ‘Source’ dropdown, choose ‘Data Sets’.
  3. In ‘Destination’, choose ‘None’. Choose a destination.
  4. For ‘File Name’, choose ‘Data Set Name’ as long as you know your data sets all have unique names.
  5. Finally, choose an error reporting option. Click ‘OK’.

illustrator-variable-PDF-files

This batch process will save a series of PDF files where you tell it to. Voilà! You’re done. Now you have the skills and knowledge to create dozens, if not hundreds of Illustrator files with variable content.