Copy link to clipboard
Copied
Hi everyone!
I've found this script on an old topic and it's exactly what I need, however when I run it on JavaScript I get this message "found.createOutlines is not a function". Can anyone have a look on it for me?
var doc = app.activeDocument;
app.findTextPreferences = null;
app.findTextPreferences.appliedCharacterStyle = "Pink Text";
var found = doc.findText();
for(var i =0;i<found.length;i++)
{
found.createOutlines();
}
app.findTextPreferences = null;
Thanks in advance,
Rogerio
Hello @Rogerio5C09,
Give this a try....
var doc = app.activeDocument;
app.findTextPreferences = null;
app.findTextPreferences.appliedCharacterStyle = "Pink Text";
var found = doc.findText();
for(var i =0;i<found.length;i++)
{
found[i].createOutlines();
}
app.findTextPreferences = null;
Regards,
Mike
Hi @Rogerio5C09,
This could also crash for other characters like whitespace characters etc. So one way to avoid the issue is to enclose the createOutlines method call in a try catch block so if the operation fails the code still moves ahead ignoring the error. Try the following code snippet
var doc = app.activeDocument;
if(doc.characterStyles.item("Pink Text") == null) {
alert('Error!\n The Character Style "Pink Text" doesn'+"'"+'t exist. Create and apply the Character Style Pink Text and try a
...
Here's the link to the script in case anyone needs it:
https://community.adobe.com/t5/indesign-discussions/convert-outlines-back-into-live-text/m-p/13388168#M505122
Regards,
Rogerio
Copy link to clipboard
Copied
Never outline Text in InDesign.
Copy link to clipboard
Copied
Hello @Rogerio5C09,
Give this a try....
var doc = app.activeDocument;
app.findTextPreferences = null;
app.findTextPreferences.appliedCharacterStyle = "Pink Text";
var found = doc.findText();
for(var i =0;i<found.length;i++)
{
found[i].createOutlines();
}
app.findTextPreferences = null;
Regards,
Mike
Copy link to clipboard
Copied
It worked! Thank you so much Mike! 🙂
Copy link to clipboard
Copied
Hi Mike,
I would like to include an alert in case there isn't a Character Style called 'Pink Text" in the document. I have tried to do it myself, but no luck 😞 Could you please have a look?
var myCharacterStyleName = "'Pink Text'";
if (to be completed) {
alert("Create a Character Style called " + myCharacterStyleName, "Outline Pink Text" , true);
}
var doc = app.activeDocument;
app.findTextPreferences = null;
app.findTextPreferences.appliedCharacterStyle = "Pink Text";
var found = doc.findText();
for(var i =0;i<found.length;i++)
{
found[i].createOutlines();
}
app.findTextPreferences = null;
Thanks in advance,
Rogerio
Copy link to clipboard
Copied
Give this a try...
var doc = app.activeDocument;
if(doc.characterStyles.item("Pink Text") == null) {
alert('Error!\n The Character Style "Pink Text" doesn'+"'"+'t exist. Create and apply the Character Style Pink Text and try again.');
exit();
}
app.findTextPreferences = null;
app.findTextPreferences.appliedCharacterStyle = "Pink Text";
var found = doc.findText();
for(var i =0;i<found.length;i++)
{
found[i].createOutlines();
}
app.findTextPreferences = null;
Regards,
Mike
Copy link to clipboard
Copied
Hi Mike,
Thanks for that! 🙂
I also need a version that keeps the editable formatted text in the document (right after the outline one). I created a hidden condition for the same. So, the script find the text by formatting (as usual), 1) duplicate each (right after in the same line); 2) outline the original formatted text; 3) find all the duplications by formatting and apply hidden condition 'Editable Text', so that only the outline text is visible in the document. Would that be possible?
Thanks,
Rogerio
Copy link to clipboard
Copied
Here's the link to the script in case anyone needs it:
https://community.adobe.com/t5/indesign-discussions/convert-outlines-back-into-live-text/m-p/1338816...
Regards,
Rogerio
Copy link to clipboard
Copied
Hi @Mike Bro ,
I hope you're doing well 🙂
I have learned that if the Character Style is applied to only a paragraph mark (without any text along with), the script fails - see screenshots. Can we also create an alert for that? You can write "Please select one or more characters that can be converted to outlines and try again."
Thanks in advance,
Rogerio
Copy link to clipboard
Copied
Hi @Rogerio5C09,
This could also crash for other characters like whitespace characters etc. So one way to avoid the issue is to enclose the createOutlines method call in a try catch block so if the operation fails the code still moves ahead ignoring the error. Try the following code snippet
var doc = app.activeDocument;
if(doc.characterStyles.item("Pink Text") == null) {
alert('Error!\n The Character Style "Pink Text" doesn'+"'"+'t exist. Create and apply the Character Style Pink Text and try again.');
exit();
}
app.findTextPreferences = null;
app.findTextPreferences.appliedCharacterStyle = "Pink Text";
var found = doc.findText();
for(var i =0;i<found.length;i++)
{
try{
found[i].createOutlines();
}catch(e){}
}
app.findTextPreferences = null;
-Manan
Copy link to clipboard
Copied
Just a note:
The ExtendScript code you copied over was damaged when the thread was moved from the old InDesign Scripting Forum to this new one in October 2019. Iterator [i] was dropped in the code. A typical error by the merging process of the forum threads back then. Thankfully Mike @Mike Bro already posted the repaired code over there:
Thanks,
Uwe Laubender
( Adobe Community Expert )