« iMovie HD その2 | メイン | MacOS X 10.2.8 »

2005年02月09日

InDesign CS + JS での校正

InDesign CS + JS での校正システムもどき(正規表現で文字を置換するだけだけど)を作成してみたら、スタイルなどが引き継がれずにおかしくなってしまう状態。contentsプロパティではない、何か別のを探さないといけないのかなあ。
実際のスクリプトは以下のようなものです。

TAB = String.fromCharCode(9); // タブコード
fileObj = new File("Macintosh HD:data.txt");
flag = fileObj.open("r");
if (flag)
{
// 単語読み込み
srcText = new Array();
repText = new Array();
count = 0;
while(!fileObj.eof)
{
text = fileObj.readln(); // 1行読み込む
txtItem = text.split(TAB); // タブコードで分割
srcText[count] = txtItem[0]; // 元の文字
repText[count] = txtItem[1]; // 置換する文字
count = count + 1;
}
// 検索・置換処理
pageObj = app.activeDocument.selection;
for (i=0; i {
for (j=0; j {
regObj = new RegExp(srcText[j],"g");
pageObj[i].contents = pageObj[i].contents.replace(regObj, repText[j]);
}
}
}

投稿者 openspc : 2005年02月09日 23:19

コメント

コメントしてください




保存しますか?