Quantcast
Channel: Adobe Community: Message List - InDesign Scripting
Viewing all articles
Browse latest Browse all 37788

Re: Need to get all the text from the particular applied character style

$
0
0

Hi Chinnadk,

 

Please try this code also, may it will be helpful..

 

.Txt file generate in the document file path with the character style contents.

 

 

var myDoc = app.activeDocument;

contents = new Array;

app.findTextPreferences = app.changeTextPreferences = null;

app.findTextPreferences.appliedCharacterStyle = "aa";    //declared character style

 

var myFound = myDoc.findText();

for(k=0; k<myFound.length; k++)

{

    contents.push(myFound[k].contents);

//~     alert(contents)

    }

 

 

//To collect content in .txt format

var myFilePath = myDoc.filePath;

var myDocName = myDoc.name.split(".indd").join("_contents.txt");

var myTextFile = File(myFilePath+ "/" + myDocName);

myTextFile.open("w");

myTextFile.write(contents);

myTextFile.close();

 

 

If you need any more clarification please let me know.....

 

Thanks

Beginner


Viewing all articles
Browse latest Browse all 37788

Trending Articles