Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automate image generation

Status
Not open for further replies.

tonecold

MIS
Oct 12, 2006
1
US
Hi All,

I am a novice when it comes to AI so I'm hoping someone here may be able to provide some tips on the problem I'm facing.

I have created a template of a football with a child's first name on top of the football and their last name beneath the football. Obviously I can type over the first and last names to create the personalized image for each player but I have hundreds of names to do.

I already have all of the names in a delimted text file. Is there any way to automate the process by reading a file and inserting the first/last names?

TIA

 
It can be done, but it's a little tricky. It involves creating an XML file stored in a particular way with all the required data. Try this (I'm sure there's a better way):

1. Open your Illustrator file, and open the Variables palette (Window > Variables)
2. Select the text path containing the child's first name, then in the Variables palette, choose "Make Text Dynamic". This will give you a new variable, which you can rename if you like.
3. Repeat step 2 with the text path containing the last name.
4. Click on the "Camera" icon to capture a data set (the default name will be "Data Set 1", but you can rename it if you like).
5. Go to "Save Variable Library" in the palette's menu to save an XML file.

Now, at this point, you can open the XML file in your editor of choice (notepad will work). Look for the following code (some names will be different depending on how you named everything)
Code:
<v:sampleDataSets  xmlns:v="&ns_vars;" xmlns="&ns_custom;">
	<v:sampleDataSet  dataSetName="Names">
		<Variable1>
			<p>First Name</p>
		</Variable1>
		<Variable2>
			<p>Last Name</p>
		</Variable2>
	</v:sampleDataSet>
</v:sampleDataSets>
The next stage is to create a <v:sampleDataSet ...> tag for each line of your tab-delimited file, and replace or append the existing tag. For example, let's say your original file looks like this:
John <tab> Smith
Jane <tab> Doe
Tom <tab> Lane

...then the portion of the XML file shown above should become:

Code:
<v:sampleDataSets  xmlns:v="&ns_vars;" xmlns="&ns_custom;">
	<v:sampleDataSet  dataSetName="[red]Name1[/red]">
		<Variable1>
			<p>[blue]John[/blue]</p>
		</Variable1>
		<Variable2>
			<p>[blue]Smith[/blue]</p>
		</Variable2>
	</v:sampleDataSet>

	<v:sampleDataSet  dataSetName="[red]Name2[/red]">
		<Variable1>
			<p>[blue]Jane[/blue]</p>
		</Variable1>
		<Variable2>
			<p>[blue]Doe[/blue]</p>
		</Variable2>
	</v:sampleDataSet>

	<v:sampleDataSet  dataSetName="[red]Name3[/red]">
		<Variable1>
			<p>[blue]Tom[/blue]</p>
		</Variable1>
		<Variable2>
			<p>[blue]Lane[/blue]</p>
		</Variable2>
	</v:sampleDataSet>
</v:sampleDataSets>
Although it looks like there is a lot of text, most of it is just repeated, so a simple Find and Replace might be enough to add in all the markup to your existing file. However, keep in mind that each line (the <v:sampleDataSet ... tag above) needs to have a unique dataSetName (in red). You might be able to add a field in a spreadsheet that numbers each line to make it unique. The original XML file also has other markup, so make sure you retain all this information and only replace the area shown.

Once you have the XML file the way you want it, go back to your Illustrator file. In the Variables palette, go to "Load Variable Library..." and pick your new XML file. Click OK when a warning about overwriting appears. Pick the first dataset from the variables palette. Now, to change your artwork to another name, simply use the arrows on the Variables palette.

As you can see, variable data in Illustrator is tricky. Using scripts, you might be able to simplify much of the work, but that's a whole new topic. Personally, I'd recommend using InDesign CS2 instead to overprint the text over your illustration. It's much easier to set up, you can use your tab-delimited file directly, and you can print all the names in one go.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top