I have two text boxes that I need to have identical text, but in different fonts. Is there any way I can edit only the text content of both at the same time (keeping the fonts different).
3 Answers
You can dynamically load text into Illustrator using an XML file.
Using the Variables panel, you can import an XML file and use that to control the existence of objects, what images appear in linked image containers, and what text appears in a text frame. You can also control the data that appears in a graph. The typical workflow is to create a template document and then tag it for variables.
There are multiple tutorials online discussing how to do this. This article: HOW TO USE ADOBE ILLUSTRATOR VARIABLE DATA WITH XML has a good video and step by step tutorial on how to do this.
Or you can do either of the following:
1) Delete the second text box. Make the text change. Copy -> paste text and apply the font or character style.
or
2) Just copy the text and paste into the other text box after finishing editing the first text box.
-
Great, will try out the first option. I've been changing text manually but would be good to automate it somehow. Thank you!– A VictorCommented May 6, 2015 at 0:40
You can use this short little snippet of a script:
#target illustrator
function ChangeTextContents(){
if(app.documents.length > 0 && app.documents[0].selection != null){
var newText = prompt("Enter new text:", "");
if(newText != null){
var sel = app.activeDocument.selection;
for(var i=0; i<sel.length; i++){
var s = sel[i];
if(s.typename == "TextFrame"){
s.contents = newText;
}
};
}
}
}
ChangeTextContents();
It will simply put your input text into the text frames that you will need to have in a selection.
Here's a modification that allows you to select groups and it changes the text within those groups. This works on nested levels (groups within groups) or on selected text layers directly.
#target illustrator
function ChangeTextContents(){
if(app.documents.length > 0 && app.documents[0].selection != null){
var newText = prompt("Enter new text:", "");
if(newText != null){
var sel = app.activeDocument.selection;
for(var i=0; i < sel.length; i++){
ChangeElement(sel[i],newText);
}
}
}
}
function ChangeElement(thisSelection,text) {
// For each selected item, determine if it is text or a group
// For text items, just change the contents
if(thisSelection.typename == "TextFrame"){
thisSelection.contents = text;
// For group items, iterate through each group item and recursive call this function.
} else if (thisSelection.typename == "GroupItem") {
// Change the text items within this level of the group
for(var k=0; k < thisSelection.textFrames.length; k++){
ChangeElement(thisSelection.textFrames[k],text);
}
// Now recursively process the group items within this group
for(var j=0; j < thisSelection.groupItems.length; j++){
ChangeElement(thisSelection.groupItems[j],text);
}
}
}
ChangeTextContents();
-
Hello Rik, welcome to GD.SE and thanks for your answer! Please have a look at the tour and the help center to get an idea of how Stack Exchange works--we're not just a random forum. Once your reputation reaches 20, you're also more than welcome to join us in Graphic Design Chat. Keep contributing and enjoy the site!– VincentCommented Aug 24, 2017 at 14:32