0

I'm just starting with Indesign (CS5) scripting.

I Try to get content (text) by char style. I made a little script, it's work when I diplay in alert the content, but not when I try to write it to a txt file. do you have any idea ??

var myDoc = app.activeDocument;
var myTextFile = File ("C:/Users/julien/Documents/catalogues/mapping/test.txt");
myTextFile.open ("w");
Products = new Array;
var tosearch = "myStyle" ;
app.findTextPreferences = null
app.changeTextPreferences = null;
app.findTextPreferences.appliedCharacterStyle = tosearch;
var  myFound = myDoc.findText ();
for (i = 0; i <myFound.length; i++){
    myTextFile.write (myFound[i].contents);
    alert(myFound[i].contents);
    myTextFile.write ("\n");
}
myTextFile.close (); 

And last but not list, I try to find on what page data come from, but exept the selected page, I didn't find how to get page number for my "found text".

Many thanks

Mitchum
  • 107
  • 2
  • 16

1 Answers1

0

I just did the "trick" adding a

myTextFile.encoding = 'UTF-8'

just before open my file !!!

Mitchum
  • 107
  • 2
  • 16