• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
0

[Old topic] Find Text by Formatting and convert to outline

Participant ,
Oct 26, 2022 Oct 26, 2022

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

TOPICS
Scripting

Views

432

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 3 Correct answers

Advisor , Oct 26, 2022 Oct 26, 2022

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

Votes

Translate

Translate
Community Expert , Nov 18, 2022 Nov 18, 2022

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
...

Votes

Translate

Translate
Participant , Dec 01, 2022 Dec 01, 2022

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



Votes

Translate

Translate
Community Expert ,
Oct 26, 2022 Oct 26, 2022

Copy link to clipboard

Copied

Never outline Text in InDesign.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 26, 2022 Oct 26, 2022

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 26, 2022 Oct 26, 2022

Copy link to clipboard

Copied

It worked! Thank you so much Mike! šŸ™‚

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 28, 2022 Oct 28, 2022

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 28, 2022 Oct 28, 2022

Copy link to clipboard

Copied

@Rogerio5C09,

 

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 31, 2022 Oct 31, 2022

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 01, 2022 Dec 01, 2022

Copy link to clipboard

Copied

LATEST

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



Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 18, 2022 Nov 18, 2022

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."

Capture1.PNG

Capture2.PNG
Thanks in advance,
Rogerio

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 18, 2022 Nov 18, 2022

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 29, 2022 Oct 29, 2022

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:

https://community.adobe.com/t5/indesign-discussions/find-text-by-formatting-and-convert-to-outline/m...

 

Thanks,
Uwe Laubender
( Adobe Community Expert )

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines