Using the Variables panel in Illustrator, you can easily create multiple variations of your artwork by merging a data source file (CSV or XML file) with an Illustrator document. For example, instead of manually modifying objects in a template, use the data merge functionality to produce hundreds of template variations for different output surfaces quickly and accurately. Similarly, you can change the names of participants on event badges, or vary images across web banners and postcards, without having to redo your artwork. Simply create one design and then quickly produce variations by importing the names or the images from a data source file.

variable-panel
Create custom variations of your design template for different projects, such as printable posters, web banners, and event badges, using the Variables panel.

Prerequisites

All you need for data merge is a data source file and a target document. 

  • The data source file contains the information that varies in each iteration of the target document, such as the names, photographs, and addresses of the recipients of a form letter. A data source file can be a comma-delimited file (.csv) or an extensible markup language file (.xml). 
  • The target document is an Illustrator document that contains the base artwork to use as the template. This document can contain the data-field placeholder and the items that remain the same in each iteration of the merged document.

Access the data merge functionality

Data merge is accessible from the Variables panel in Illustrator (Window > Variables). The type and name of each variable in the document are listed in the panel. If the variable is bound to an object, then the Objects column displays the name of the bound object as it appears in the Layers panel. You can sort the rows by clicking items in the header bar: by variable name, object name, or by variable type.

Variables panel
Variables panel

A. Data set B. Panel menu C. Switch between data sets D. Name of bound object E. Variable name F. Variable type G. Lock variables H. Make object dynamic I. Make visibility dynamic J. Unbind variables K. Create variables L. Delete variables 

Quick steps for merging data

  1. Create an Illustrator document to use as the template.

  2. Set up your source data file in CSV or XML format. For more information, see Prepare a data source file.

  3. Import a data source file in Illustrator using the Variables panel. For more information, see Import a data source file.

  4. Bind a variable to an object in your template. For more information, see Bind variables to objects.

  5. Preview the document with each data set before you export all the files. For more information, see Preview the document with each data set.

  6. Export a batch of files from the data using the Actions panel in Illustrator. For more information, see Export files using the Actions panel.

Prepare a data source file

Data source files should be saved in a comma-delimited (.csv) or Extensible Markup Language (.xml) format.

Set up your CSV source files

In a comma-delimited (.csv) file, records are separated by paragraph breaks; fields are separated by commas or tabs. The data source file can also include text or paths that see images on disk. Before importing a CSV file, do the following to let Illustrator identify the variable type.

  1. Open your spreadsheet.

  2. Specify your data field name in the first row of your spreadsheet. Then, do the following:

    • At the beginning of the data field name, type an “at” symbol (@) to insert text or paths that refer to image files. The @ symbol is required only in the first line; subsequent lines should include the image paths.
    • Similarly, at the beginning of the data field name, type a “percentage” symbol (%) for graphs and a "hashtag" symbol (#) for visibility.

    Poznámka:

    • The data field names in your spreadsheet should not contain blank spaces. For example, you can specify the data field as Company_Name instead of Company Name
    • Similarly, the paths referring to image and graph files should not contain any blank spaces. For example, the path of an image file should be C:\Photos\BillTucker instead of C:\Photos\Bill Tucker.
    • All graph files linked from your data source file should be saved as comma-delimited (.csv) files.
    • If you get an error message when you type the @ symbol at the beginning of the field, type an apostrophe (') before the @ symbol (such as '@Photos) to validate the function. Some applications, such as Microsoft Excel, reserve the @ symbol for functions.

    (Windows) Example of image and graph references in the data source file

    Name Age @Photos %Graphs
    Bill Tucker 36 C:\Photos\BillTucker.jpg C:\Photos\BillTucker.csv
    Dat Nguyen 53 C:\MyDocuments\dat.jpg C:\MyDocuments\dat.csv
    Maria Ruiz 26 C:\Photos\Ruiz.jpg C:\Photos\Ruiz.csv

    (macOS) Example of image and graph references in the data source file

    Name Age @Photos %Graphs
    Bill Tucker 36 /Users/photos/BillTucker.jpg
    /Users/photos/BillTucker.csv
    Dat Nguyen 53 /Users/family/photos/dat.jpg
    /Users/family/photos/dat.csv
    Maria Ruiz 26 /Users/alpha/photos/Ruiz.jpg /Users/alpha/photos/Ruiz.csv
  3. Enter your data into the spreadsheet.

  4. Do one of the following:

    • Save spreadsheets created using the latest version of Microsoft Excel (2016 release) to the following file formats:
      • CSV (Comma delimited) (*.csv)
      • CSV (MS-DOS) (*.csv)
    • Save spreadsheets created using Apple Numbers to CSV format with Unicode (UTF-8) encoding.

    Poznámka:

    Currently, CSV files exported in the formats mentioned above are supported in Illustrator. Other CSV file formats such as Macintosh Comma Separated (.csv) are not supported for data merge.

Prepare an XML file

  1. Define a variable in your document. For details, see Bind variables to objects.

  2. Click the Capture Data Set button () in the Variables panel. Alternatively, choose Capture Data Set from the Variables panel menu.

  3. After creating the desired number of data sets, choose Save Variable Library from the Variables panel menu to save the data sets as an XML file. Specify the filename and location, and click Save.

    save-variable-as-xml-file
    Export the variables you've created in Illustrator as an XML file
  4. Now, edit the XML file in a text editing application such as Notepad++ (Windows) or TextWrangler (macOS) to include your data sets in this file.

    example-XML-file
    Example: editing an XML file using any text editing application

    A. Replace the path of the image B. Replace the string of text  
  5. To import your XML file in Illustrator, choose Load Variable Library from the Variables panel menu. Select the XML file and click Open.

    load-variable-to-data-set
    Import variables into Illustrator

Import a data source file

To bind variables to the desired data, import a data source in the Variables panel. You can have only one data source file selected per document.

  1. Choose Window > Variables.

  2. In the Variables panel, click Import.

    import-data-set_1
    Import a data source file using the Variables panel
  3. In the Load Variable Library dialog box, select a data source file in CSV or XML format and click Open.

    select-a-data-source-file_1
    Select a CSV or XML data source file
  4. (Optional) You can edit, rename, or delete the data set later by first choosing it from the Data Set drop‑down menu and editing its options.

    • To switch between data sets, select a data set from the Data Set list in the Variables panel. Alternatively, click the Previous Data Set button () or the Next Data Set button ().
    • To apply the data on the artboard to the current data set, choose Update Data Set from the Variables panel menu.
    • To rename a data set, edit the text directly in the Data Set text box. Alternatively, double-click the words Data Set (to the left of the Data Set text box), enter a new name, and click OK.
    • To delete a data set, click the Delete icon. Alternatively, choose Delete Data Set from the Variables panel menu.

Bind variables to objects

Use variables to define the elements in a template that you want to change. You can define four types of variables: Visibility variable, Text String variable, Linked File variable, and Graph Data variable. A variable’s type indicates which object attributes are changeable (dynamic). The type and name of each variable in the document are listed in the panel. If the variable is bound to an object, then the Objects column displays the name of the bound object as it appears in the Layers panel.

Type of variable Icon to indicate a variable’s type
Definition
Visibility variables Show or hide artwork.
Text String variables Replace a string of text.
Linked File variables Replace the object in the artboard with an object from another file.
Graph Data variables Replace the values in a graph.
No Type (unbound) variable Not bound to any object.

To define variables in Illustrator, do the following:

  1. Select an object.

  2. In the Variables panel (Window > Variables), select the variable you want to bind it with.

  3.  To bind the object with the variable, do one of the following:

    • Click the Make Object Dynamic () button.
    • Choose Make Object Dynamic from the panel menu.

To create a variable without binding it to an object, do the following:

  1. Click the New Variable button () in the Variables panel or choose New Variable from the panel menu.

  2. To subsequently bind an object to the variable, select the object and the variable, and click the Make Visibility Dynamic button () or the Make Object Dynamic button (). Alternatively, choose one of these options from the panel menu.

Work with variables

You can edit a variable’s name or type, unbind a variable, and lock a variable using the Variables panel.

Unbinding a variable breaks the link between the variable and its object. Locking variables prevents you from creating variables, deleting variables, and editing variable options. However, you can bind and unbind objects to locked variables.

Change the name and type of a variable

  1. Double-click the variable in the Variables panel. Alternatively, select the variable in the Variables panel, and choose Variable Options from the Variables panel menu.

Unbind a variable

  1. Click the Unbind Variable button () in the Variables panel, or choose Unbind Variable from the Variables panel menu.

Lock or unlock all variables in a document

  1. Click the Lock/Unlock Variables button  or  in the Variables panel.

Delete variables

Deleting a variable removes it from the Variables panel. If you delete a variable that is bound to an object, the object becomes static (unless the object is also bound to a variable of a different type).

  1. Select a variable you want to delete.

  2. Do one of the following:

    • Click the Delete Variable button () in the Variables panel, or choose Delete Variable from the Variables panel menu.

    • To delete the variable without confirmation, drag it to the Delete Variable button ().

Edit dynamic objects

You can change the data associated with a variable by editing the object to which it is bound. For example, if you’re working with a Visibility variable, you change the object’s state of visibility in the Layers panel. Editing dynamic objects lets you create multiple data sets for use in the template.

  1. Select a dynamic object on the artboard, or do one of the following to automatically select a dynamic object:

    • Alt‑click (Windows) or Option‑click (Mac OS) a variable in the Variables panel.

    • Select a variable in the Variables panel, and choose Select Bound Object from the Variables panel menu.

    • To select all dynamic objects, choose Select All Bound Objects from the Variables panel menu.

  2. Edit the data associated with the object as follows:

    • For text, edit the text string on the artboard.

    • For linked files, replace the image using the Links panel or the File > Place command.

    • For graphs, edit the data in the Graph Data dialog box.

    • For all objects with dynamic visibility, change the state of visibility for the object in the Layers panel.

Identifying dynamic objects usingXML IDs

The Variables panel displays the names of dynamic objects as they appear in the Layers panel. If you save the template in SVG format for use with other Adobe products, these object names must conform to XML naming conventions. For example, XML names must begin with a letter, underscore, or colon, and cannot contain spaces.

Illustrator automatically assigns a valid XML ID to every dynamic object you create. To view, edit, and export object names using XML IDs, choose Edit > Preferences > Units (Windows) or Illustrator > Preferences > Units (Mac OS), and select XML ID.

Preview the document with each data set

To see how your final graphics will look, you can preview before you export all the files. Use the arrow keys next to Data Set in the Variables panel to navigate and preview the desired data set in your document.

Export files using the Actions panel

After you define variables and one or more data sets, you can output, in batch mode, artwork using the data set values. Do the following:

  1. Using the Actions panel (Window > Actions), record an action to save your document in the desired format. For details, see Automation with actions.

  2. Choose Batch from the Actions panel menu and select the action you’ve created in the previous step.

  3. For Source, select Data Sets to play the action on each dataset in the current file.

  4. For Destination, specify what you want to do with the processed files. You can leave the files open without saving the changes (None), save and close the file in their current location (Save And Close), or save the files to a different location (Folder).

    Depending on the Destination option you select, you can set additional options for saving the files. For more information, see Play an action on a batch of files.

  5. Click OK.

Save a template for data merge

When you define variables in an Illustrator document, you are creating a template for data merge. You can save the template in SVG format for use with other Adobe products, such as Adobe® Graphics Server. For example, a developer working with Adobe Graphics Server can bind the variables in the SVG file directly to a database or another data source.

  1. Choose File > Save As, enter a filename, select SVG as the file format, and click Save.

  2. Click More Options, and select Include Adobe Graphics Server Data. This option includes all information needed for variable substitution in the SVG file.

  3. Click OK.

Facing issues while importing your CSV file?

If you’re receiving the error: The incoming variable library is invalid while uploading a CSV data source file, check for the following:

  • Your CSV file is not blank.
  • The spreadsheets that you've created using the latest version of Microsoft Excel are saved as CSV (Comma delimited) (*.csv) or CSV (MS-DOS) (*.csv) and those created using Apple Numbers are saved as CSV format with Unicode (UTF-8) encoding. Data source files saved in any other file format such as Macintosh Comma Separated (*.csv) are not supported for data merge.
  • All columns have a data field name. For example, Illustrator displays the error message when a column in your data source file contains data but doesn't have a data field name.
  • The data source file doesn't have a blank column in between any filled columns. For example, Illustrator displays the error message when column B and D in your data source file contain data but column C is empty.
Example-errors-while-importing-CSV-files
Example: errors while setting up a CSV source file for data merge

A. Data field name is missing for a column B. There's a blank column between filled columns 
  • The data field names in your spreadsheet don't contain any blank spaces.
  • The paths referring to image and graph files in your source file don't contain any blank spaces.
  • The graph files linked from your data source file are saved as comma-delimited (.csv) files.

Licencia na používanie tohto diela sa poskytuje v súlade s podmienkami licencie Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Na príspevky v sociálnych sieťach Twitter™ a Facebook sa nevzťahujú podmienky licencií Creative Commons.

Právne upozornenia   |   Zásady ochrany osobných údajov online