InDesign CS3自動化作戦 (InDesign CS3 Automation Operation)

テキストフレームの座標を表示する

■プログラム説明(ソースコード説明)
 テキストフレームの座標を求めるにはgeometricBoundsまたはvisibleBounds配列を参照します。順番にy1,x1,y2,x2の座標の順番で入っています。値は単位のなしで、現在設定されている単位での値になります。

■ソースコード
txtObj = app.activeDocument.selection[0];
x1 = txtObj.geometricBounds[1];
y1 = txtObj.geometricBounds[0];
x2 = txtObj.geometricBounds[3];
y2 = txtObj.geometricBounds[2];
alert("("+x1+","+y1+")-("+x2+","+y2+")");


■使い方
1:座標を表示するテキストフレームを選択します。
2:スクリプトを実行します。
3:座標が表示されます。


■ポイント
 visibleBoundsの場合は以下のようになります。

txtObj = app.activeDocument.selection[0];
x1 = txtObj.visibleBounds[1];
y1 = txtObj.visibleBounds[0];
x2 = txtObj.visibleBounds[3];
y2 = txtObj.visibleBounds[2];
alert("("+x1+","+y1+")-("+x2+","+y2+")");

■実際のスクリプトをダウンロード(sample.jsx.zip)

写真素材 PIXTA